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); }
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); }