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 addLocationViewProvider ( eZ\Publish\Core\MVC\Symfony\View\ViewProvider $viewProvider, integer $priority ) | ||
$viewProvider | eZ\Publish\Core\MVC\Symfony\View\ViewProvider | |
$priority | integer |
public function testLocationViewProvidersPriority() { list($high, $medium, $low) = $this->createLocationViewProviderMocks(); $this->viewManager->addLocationViewProvider($medium, 33); $this->viewManager->addLocationViewProvider($high, 100); $this->viewManager->addLocationViewProvider($low, -100); self::assertSame(array($high, $medium, $low), $this->viewManager->getAllLocationViewProviders()); }
public function testRenderLocationWithClosure() { $viewProvider = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\View\\Provider\\Location'); $this->viewManager->addLocationViewProvider($viewProvider); $location = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Location'); $content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content'); $contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo'); // Configuring view provider behaviour $closure = function ($params) { return serialize(array_keys($params)); }; $params = array('foo' => 'bar'); $viewProvider->expects($this->once())->method('getView')->with($location)->will($this->returnValue(new ContentView($closure, $params))); $contentService = $this->getMockBuilder("eZ\\Publish\\Core\\Repository\\ContentService")->disableOriginalConstructor()->getMock(); $contentService->expects($this->any())->method("loadContentByContentInfo")->with($contentInfo)->will($this->returnValue($content)); $this->repositoryMock->expects($this->any())->method("getContentService")->will($this->returnValue($contentService)); $location->expects($this->any())->method("getContentInfo")->will($this->returnValue($contentInfo)); // Configuring template engine behaviour $params += array('location' => $location, 'content' => $content, 'viewbaseLayout' => $this->viewBaseLayout); $expectedTemplateResult = serialize(array_keys($params)); $this->templateEngineMock->expects($this->never())->method('render'); self::assertSame($expectedTemplateResult, $this->viewManager->renderLocation($location)); }