function testVisitUrlCompositeWithActiveParent() { $parent = new T_Url_Collection('parent', 'test', 'p.com'); $child1 = new T_Url_Leaf('child1', 'test', 'c1.com'); $child2 = new T_Url_Leaf('child2', 'test', 'c2.com'); $parent->setActive(); $parent->addChild($child1); $parent->addChild($child2); ob_start(); // execute visitor $parent->accept($this->visitor); $xhtml = ob_get_contents(); ob_end_clean(); $expected = EOL . '<a class="cur parent" href="test://p.com">parent</a>' . EOL . '<ul>' . EOL . $this->indent . '<li><a href="test://c1.com">child1</a></li>' . EOL . $this->indent . '<li><a href="test://c2.com">child2</a></li>' . EOL . '</ul>'; $this->assertSame($xhtml, $expected); }
function testMultiActiveAtSingleLevelException() { $parent = new T_Url_Collection('parent', 'test', 'p.com'); $child1 = new T_Url_Leaf('child1', 'test', 'c1.com'); $child2 = new T_Url_Collection('child2', 'test', 'c2.com'); $child2->setActive(); $child1->setActive(); $parent->addChild($child1); $parent->addChild($child2); ob_start(); try { $parent->accept($this->visitor); $this->fail(); } catch (OutOfRangeException $e) { } ob_end_clean(); }