Source of file PageSeoExtensionTest.php
Size: 1,932 Bytes - Last Modified: 2021-12-23T10:57:22+00:00
/var/www/docs.ssmods.com/process/src/tests/Extensions/PageSeoExtensionTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | <?php namespace QuinnInteractive\Seo\Tests\Extensions; use SilverStripe\Control\Director; use SilverStripe\Dev\FunctionalTest; use SilverStripe\ORM\FieldType\DBDatetime; use QuinnInteractive\Seo\Extensions\PageSeoExtension; use QuinnInteractive\Seo\Seo; class PageSeoExtensionTest extends FunctionalTest { protected static $fixture_file = '../Pages.yml'; /** @var \Page|PageSeoExtension */ protected $page; public function setUp() { parent::setUp(); $this->page = $this->objFromFixture(\Page::class, 'one'); } public function testPageHasExtension() { $this->assertTrue($this->page->hasExtension(PageSeoExtension::class)); $this->assertInstanceOf(\Page::class, $this->page->getOwner()); } public function testCanonicalLink() { $this->assertContains(Director::absoluteBaseURL(), Seo::getCanonicalUrlLink($this->page)[0]); } public function testArticleTags() { /** @var DBDatetime $created */ $created = $this->page->dbObject('Created'); /** @var DBDatetime $lastEdited */ $lastEdited = $this->page->dbObject('LastEdited'); $this->assertContains( $created->Rfc3339(), Seo::getArticleTags($this->page)[0] ); $this->assertContains( $lastEdited->Rfc3339(), Seo::getArticleTags($this->page)[1] ); } public function testMetaTags() { $tags = $this->page->MetaTags(false); $this->assertContains(Seo::getCanonicalUrlLink($this->page)[0], $tags); $this->assertContains(Seo::getArticleTags($this->page)[0], $tags); $this->assertContains(Seo::getArticleTags($this->page)[1], $tags); $this->assertContains(implode(PHP_EOL, Seo::getFacebookMetaTags($this->page)), $tags); $this->assertContains(implode(PHP_EOL, Seo::getTwitterMetaTags($this->page)), $tags); } } |