Esempio n. 1
0
 public function testRenderIgnoreModelWithoutGroupId()
 {
     $root = new ViewModel();
     $ignored = new ViewModel();
     $root->addChild($ignored);
     $ignored->setGroupId(null);
     $events = $this->getMock(Events::CLASS, ['trigger']);
     $view = new View();
     $view->setEvents($events);
     $events->expects($this->atLeastOnce())->method('trigger')->with($this->callback(function ($event) use($ignored) {
         $this->assertInstanceOf(ViewEvent::CLASS, $event);
         $model = $event->getContext();
         $this->assertInstanceOf(ViewModelInterface::CLASS, $model);
         if ($model === $ignored) {
             return false;
         }
         return true;
     }));
     $view->render($root);
 }
Esempio n. 2
0
 public function testGetIterator()
 {
     $root = new ViewModel();
     $child = new ViewModel();
     $root->addChild($child, 'foo');
     $iterator = $root->getIterator();
     $this->assertInstanceOf(ArrayIterator::CLASS, $iterator);
     $children = $iterator->getArrayCopy();
     $this->assertSame([$child], $children);
 }