function testCompositeVisitsItselfNotChildrenWhenTraverseOff()
 {
     $parent = $this->getElement('parent');
     $child1 = $this->getElement('child1');
     $child2 = $this->getElement('child2');
     $parent->addChild($child1)->addChild($child2);
     $visitor = new T_Test_VisitorStub();
     $visitor->setTraverseChildren(false);
     $parent->accept($visitor);
     $visited = $visitor->getVisited();
     $this->assertTrue(count($visited['object']) == 1);
     $this->assertSame($visited['object'][0], $parent);
     $this->assertSame($visited['depth'][0], 0);
 }
Пример #2
0
 function testCollectionVisitsItselfNotChildrenWhenTraverseOff()
 {
     /* create composite */
     $input = $this->getInputCollection('parent', 'mylabel');
     $child1 = new T_Test_Form_ElementStub('child1', 'label');
     $child2 = new T_Test_Form_ElementStub('child2', 'label');
     $input->addChild($child1)->addChild($child2);
     /* visit parent */
     $visitor = new T_Test_VisitorStub();
     $visitor->setTraverseChildren(false);
     $input->accept($visitor);
     $visited = $visitor->getVisited();
     /* check objects visited */
     $this->assertTrue(count($visited['object']) == 1);
     $this->assertSame($visited['object'][0], $input);
     $this->assertSame($visited['depth'][0], 0);
 }
Пример #3
0
 function testCompositeVisitsItselfNotChildrenWhenTraverseOff()
 {
     // add children
     $child1 = $this->getUrlComposite();
     $child2 = $this->getUrlComposite();
     $this->url->addChild($child1);
     $this->url->addChild($child2);
     // visit parent
     $visitor = new T_Test_VisitorStub();
     $visitor->setTraverseChildren(false);
     $this->url->accept($visitor);
     $visited = $visitor->getVisited();
     // check objects visited
     $this->assertTrue(count($visited['object']) == 1);
     $this->assertSame($visited['object'][0], $this->url);
     $this->assertSame($visited['depth'][0], 0);
 }