Beispiel #1
0
 function testVisitUrlCompositeWithActiveChild()
 {
     $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');
     $child2->setActive();
     $parent->addChild($child1);
     $parent->addChild($child2);
     ob_start();
     // execute visitor
     $parent->accept($this->visitor);
     $xhtml = ob_get_contents();
     ob_end_clean();
     $c2_link = '<a class="cur" href="test://c2.com">child2</a>';
     $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 class="cur">' . $c2_link . '</li>' . EOL . '</ul>';
     $this->assertSame($xhtml, $expected);
 }
Beispiel #2
0
 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();
 }