public function testRenderLocationWithClosure()
{
$content = new Content(['versionInfo' => new VersionInfo(['contentInfo' => new ContentInfo()])]);
$location = new Location(['contentInfo' => new ContentInfo()]);
// Configuring view provider behaviour
$closure = function ($params) {
return serialize(array_keys($params));
};
$params = array('foo' => 'bar');
$this->viewConfigurator->expects($this->once())->method('configure')->will($this->returnCallback(function (View $view) use($closure) {
$view->setTemplateIdentifier($closure);
}));
$contentService = $this->getMockBuilder('eZ\\Publish\\Core\\Repository\\ContentService')->disableOriginalConstructor()->getMock();
$contentService->expects($this->any())->method('loadContentByContentInfo')->with($content->contentInfo)->will($this->returnValue($content));
$this->repositoryMock->expects($this->any())->method('getContentService')->will($this->returnValue($contentService));
// Configuring template engine behaviour
$params += array('location' => $location, 'content' => $content, 'viewbaseLayout' => $this->viewBaseLayout);
$this->templateEngineMock->expects($this->never())->method('render');
$expectedTemplateResult = array_keys($params);
$templateResult = unserialize($this->viewManager->renderLocation($location, 'full', $params));
sort($expectedTemplateResult);
sort($templateResult);
self::assertSame($expectedTemplateResult, $templateResult);
}