silverstripe /
silverstripe-elemental-bannerblock
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SilverStripe\ElementalBannerBlock\Tests\Block; |
||
| 4 | |||
| 5 | use SilverStripe\CMS\Model\SiteTree; |
||
| 6 | use SilverStripe\Dev\SapphireTest; |
||
| 7 | use SilverStripe\ElementalBannerBlock\Block\BannerBlock; |
||
| 8 | use SilverStripe\Forms\HTMLEditor\TinyMCEConfig; |
||
| 9 | use SilverStripe\View\ArrayData; |
||
| 10 | use SilverStripe\View\Requirements; |
||
| 11 | |||
| 12 | class BannerBlockTest extends SapphireTest |
||
| 13 | { |
||
| 14 | protected static $fixture_file = 'BannerBlockTest.yml'; |
||
| 15 | |||
| 16 | public function testCallToActionLink() |
||
| 17 | { |
||
| 18 | $block = new BannerBlock; |
||
| 19 | $this->assertNull($block->CallToActionLink(), 'No link data set returns null'); |
||
| 20 | |||
| 21 | $block->CallToActionLink = json_encode([ |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 22 | 'PageID' => $this->idFromFixture(SiteTree::class, 'test_page'), |
||
| 23 | 'Text' => 'Click here', |
||
| 24 | 'Description' => 'Link title text', |
||
| 25 | 'TargetBlank' => true, |
||
| 26 | ]); |
||
| 27 | |||
| 28 | $result = $block->CallToActionLink(); |
||
| 29 | $this->assertInstanceOf(ArrayData::class, $result, 'ArrayData object is returned'); |
||
| 30 | $this->assertEquals($this->idFromFixture(SiteTree::class, 'test_page'), $result->Page->ID, 'Page is attached'); |
||
| 31 | $this->assertInstanceOf(SiteTree::class, $result->Page); |
||
| 32 | $this->assertSame('Link title text', $result->Description, 'Link attributes are available'); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |