From 450666cc5b7c06ccfd86889c639670de3df30b1a Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Mon, 10 Jul 2023 13:19:53 +1200 Subject: [PATCH] FIX HTML showing in inline preview --- src/Block/BannerBlock.php | 6 +----- tests/Block/BannerBlockTest.php | 12 ++++++++++++ tests/Block/BannerBlockTest.yml | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Block/BannerBlock.php b/src/Block/BannerBlock.php index c732fee..20c81cb 100644 --- a/src/Block/BannerBlock.php +++ b/src/Block/BannerBlock.php @@ -78,10 +78,7 @@ public function CallToActionLink() */ public function getSummary() { - if ($this->File() && $this->File()->exists()) { - return $this->getSummaryThumbnail() . $this->dbObject('Content')->Summary(20); - } - return ''; + return $this->dbObject('Content')->Summary(20); } /** @@ -92,7 +89,6 @@ public function getSummary() protected function provideBlockSchema() { $blockSchema = parent::provideBlockSchema(); - $blockSchema['content'] = $this->dbObject('Content')->Summary(20); return $blockSchema; } diff --git a/tests/Block/BannerBlockTest.php b/tests/Block/BannerBlockTest.php index e3eac9c..9785619 100644 --- a/tests/Block/BannerBlockTest.php +++ b/tests/Block/BannerBlockTest.php @@ -41,4 +41,16 @@ public function testNullStringCallToActionLink() $block->write(); $this->assertNull($block->CallToActionLink()); } + + public function testGetSummary() + { + /** @var BannerBlock $block */ + $block = $this->objFromFixture(BannerBlock::class, 'block_with_content'); + + $summary = $block->getSummary(); + $this->assertEquals( + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + $summary + ); + } } diff --git a/tests/Block/BannerBlockTest.yml b/tests/Block/BannerBlockTest.yml index b89486a..f91085c 100644 --- a/tests/Block/BannerBlockTest.yml +++ b/tests/Block/BannerBlockTest.yml @@ -1,3 +1,7 @@ SilverStripe\CMS\Model\SiteTree: test_page: Title: Test + +SilverStripe\ElementalBannerBlock\Block\BannerBlock: + block_with_content: + Content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. \ No newline at end of file