Source of file ModularPageTest.php
Size: 1,478 Bytes - Last Modified: 2021-12-23T10:53:22+00:00
/var/www/docs.ssmods.com/process/src/tests/ModularPageTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php class PageModuleSubclass1 extends PageModule { } class PageModuleSubclass2 extends PageModule { } class ModularPageSubclass extends ModularPage { public static $allowed_modules = array('PageModuleSubclass1'); } class ModularPageTest extends SapphireTest { protected static $fixture_file = 'ModularPageTest.yml'; /** * Test that we're able to create a ModularPage. */ public function testPageCreation() { $page = $this->objFromFixture('ModularPage', 'test'); $this->assertEquals($page->Title, 'Modular page'); } /** * Test that the page can hold a module. */ public function testAddModule() { $page = $this->objFromFixture('ModularPage', 'test'); $this->assertEquals($page->Modules()->Count(), 1); } /** * Test that the module render method is producing content. */ public function testModuleRender() { Director::setBaseURL('http://www.example.com/'); $page = $this->objFromFixture('ModularPage', 'test'); foreach ($page->Modules() as $module) { $this->assertNotEmpty($module->Content()); } } /** * Test that pages can filter the list of modules allowed. */ public function testAllowedModules() { $filteredPage = new ModularPageSubclass(); $this->assertEquals($filteredPage->getAllowedModules(), array('PageModuleSubclass1' => 'PageModuleSubclass1')); } } |