/** * Base functionality tested in {@link SiteTreeTest->testAllowedChildrenValidation()}. */ public function testAllowedChildrenLimitedOnVirtualPages() { $classA = new SiteTreeTest_ClassA(); $classA->write(); $classB = new SiteTreeTest_ClassB(); $classB->write(); $classBVirtual = new VirtualPage(); $classBVirtual->CopyContentFromID = $classB->ID; $classBVirtual->write(); $classC = new SiteTreeTest_ClassC(); $classC->write(); $classCVirtual = new VirtualPage(); $classCVirtual->CopyContentFromID = $classC->ID; $classCVirtual->write(); $classBVirtual->ParentID = $classA->ID; $valid = $classBVirtual->doValidate(); $this->assertTrue($valid->valid(), "Does allow child linked to virtual page type allowed by parent"); $classCVirtual->ParentID = $classA->ID; $valid = $classCVirtual->doValidate(); $this->assertFalse($valid->valid(), "Doesn't allow child linked to virtual page type disallowed by parent"); }
public function testAllowedChildrenValidation() { $page = new SiteTree(); $page->write(); $classA = new SiteTreeTest_ClassA(); $classA->write(); $classB = new SiteTreeTest_ClassB(); $classB->write(); $classC = new SiteTreeTest_ClassC(); $classC->write(); $classD = new SiteTreeTest_ClassD(); $classD->write(); $classCext = new SiteTreeTest_ClassCext(); $classCext->write(); $classB->ParentID = $page->ID; $valid = $classB->validate(); $this->assertTrue($valid->valid(), "Does allow children on unrestricted parent"); $classB->ParentID = $classA->ID; $valid = $classB->validate(); $this->assertTrue($valid->valid(), "Does allow child specifically allowed by parent"); $classC->ParentID = $classA->ID; $valid = $classC->validate(); $this->assertFalse($valid->valid(), "Doesnt allow child on parents specifically restricting children"); $classB->ParentID = $classC->ID; $valid = $classB->validate(); $this->assertFalse($valid->valid(), "Doesnt allow child on parents disallowing all children"); $classB->ParentID = $classC->ID; $valid = $classB->validate(); $this->assertFalse($valid->valid(), "Doesnt allow child on parents disallowing all children"); $classCext->ParentID = $classD->ID; $valid = $classCext->validate(); $this->assertFalse($valid->valid(), "Doesnt allow child where only parent class is allowed on parent node, and asterisk prefixing is used"); }