Source of file SitemapPageTest.php
Size: 2,523 Bytes - Last Modified: 2021-12-23T10:26:54+00:00
/var/www/docs.ssmods.com/process/src/tests/SitemapPageTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | <?php /** * @package silverstripe-sitemap * @subpackage tests */ class SitemapPageTest extends FunctionalTest { public static $fixture_file = 'sitemap/tests/SitemapPageTest.yml'; protected static $use_draft_site = true; public function testShowAll() { $sitemap = new SitemapPage(); $expected = array ( $this->objFromFixture('SiteTree', 'home')->Link(), $this->objFromFixture('SiteTree', 'about')->Link(), $this->objFromFixture('SiteTree', 'staff')->Link(), $this->objFromFixture('SiteTree', 'history')->Link(), $this->objFromFixture('SiteTree', 'contact')->Link() ); $this->assertEquals ( $expected, HTTP::getLinksIn($sitemap->getSitemap()), 'Assert that all valid pages are shown in the sitemap.' ); } public function testShowChildrenOf() { $sitemap = new SitemapPage(); $sitemap->PagesToDisplay = 'ChildrenOf'; $sitemap->ParentPageID = $this->idFromFixture('SiteTree', 'about'); $expected = array ( $this->objFromFixture('SiteTree', 'staff')->Link(), $this->objFromFixture('SiteTree', 'history')->Link() ); $this->assertEquals ( $expected, HTTP::getLinksIn($sitemap->getSitemap()), 'Assert that displaying the children of pages works.' ); } public function testShowSelected() { $sitemap = new SitemapPage(); $sitemap->write(); $sitemap->PagesToDisplay = 'Selected'; $sitemap->PagesToShow()->add($this->objFromFixture('SiteTree', 'about')); $sitemap->PagesToShow()->add($this->objFromFixture('SiteTree', 'contact')); $sitemap->write(); $expected = array ( $this->objFromFixture('SiteTree', 'about')->Link(), $this->objFromFixture('SiteTree', 'staff')->Link(), $this->objFromFixture('SiteTree', 'history')->Link(), $this->objFromFixture('SiteTree', 'contact')->Link() ); $this->assertEquals ( $expected, HTTP::getLinksIn($sitemap->getSitemap()), 'Assert that showing selected pages & children works.' ); } public function testShowInMenusRespected() { $sitemap = new SitemapPage(); $homePage = $this->objFromFixture('SiteTree', 'home'); $this->assertContains ( $homePage->Link(), HTTP::getLinksIn($sitemap->getSitemap()), 'The page is displayed by default.' ); $homePage->ShowInMenus = false; $homePage->write(); $this->assertNotContains ( $homePage->Link(), HTTP::getLinksIn($sitemap->getSitemap()), 'The page is displayed by default.' ); } } /** * @ignore */ class SitemapPageTest_Unviewable extends SiteTree { public function canView($member = null) { return false; } } |