When this view provider will be called in the chain depends on $priority. The highest $priority is, the earliest the router will be called.
public addContentViewProvider ( eZ\Publish\Core\MVC\Symfony\View\ViewProvider $viewProvider, integer $priority ) | ||
$viewProvider | eZ\Publish\Core\MVC\Symfony\View\ViewProvider | |
$priority | integer |
public function testContentViewProvidersPriority() { list($high, $medium, $low) = $this->createContentViewProviderMocks(); $this->viewManager->addContentViewProvider($medium, 33); $this->viewManager->addContentViewProvider($high, 100); $this->viewManager->addContentViewProvider($low, -100); self::assertSame(array($high, $medium, $low), $this->viewManager->getAllContentViewProviders()); }
public function testRenderContentWithClosure() { $viewProvider = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\View\\Provider\\Content'); $this->viewManager->addContentViewProvider($viewProvider); // Configuring content mocks $content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content'); $versionInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); $contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo'); $content->expects($this->once())->method('getVersionInfo')->will($this->returnValue($versionInfo)); $versionInfo->expects($this->once())->method('getContentInfo')->will($this->returnValue($contentInfo)); // Configuring view provider behaviour $closure = function ($params) { return serialize(array_keys($params)); }; $params = array('foo' => 'bar'); $viewProvider->expects($this->once())->method('getView')->with($contentInfo)->will($this->returnValue(new ContentView($closure, $params))); // Configuring template engine behaviour $params += array('content' => $content, 'viewbaseLayout' => $this->viewBaseLayout); $expectedTemplateResult = serialize(array_keys($params)); $this->templateEngineMock->expects($this->never())->method('render'); self::assertSame($expectedTemplateResult, $this->viewManager->renderContent($content)); }