$content will be injected in the selected template.
public renderContent ( eZ\Publish\API\Repository\Values\Content\Content $content, string $viewType = ViewManagerInterface::VIEW_TYPE_FULL, array $parameters = [] ) : string | ||
$content | eZ\Publish\API\Repository\Values\Content\Content | |
$viewType | string | Variation of display for your content. Default is 'full'. |
$parameters | array | Parameters to pass to the template called to render the view. By default, it's empty. 'content' entry is reserved for the Content that is rendered. |
Результат | string |
public function testRenderContentWithClosure() { $content = new Content(['versionInfo' => new VersionInfo(['contentInfo' => new ContentInfo()])]); // Configuring view provider behaviour $closure = function ($params) { return serialize(array_keys($params)); }; $params = ['foo' => 'bar']; $this->viewConfigurator->expects($this->once())->method('configure')->will($this->returnCallback(function (View $view) use($closure) { $view->setTemplateIdentifier($closure); })); // Configuring template engine behaviour $params += array('content' => $content, 'viewbaseLayout' => $this->viewBaseLayout); $expectedTemplateResult = array_keys($params); $this->templateEngineMock->expects($this->never())->method('render'); $templateResult = unserialize($this->viewManager->renderContent($content, 'full', $params)); sort($expectedTemplateResult); sort($templateResult); self::assertEquals($expectedTemplateResult, $templateResult); }
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)); }