本文整理汇总了PHP中Symfony\Component\Templating\EngineInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP EngineInterface::expects方法的具体用法?PHP EngineInterface::expects怎么用?PHP EngineInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Templating\EngineInterface
的用法示例。
在下文中一共展示了EngineInterface::expects方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRequestHtml
public function testRequestHtml()
{
$expectedResponse = new Response('some-html-string');
$this->templating->expects($this->once())->method('render')->will($this->returnValue($expectedResponse));
/** @var Response $response */
$response = $this->controller->indexAction('html', 'test');
$this->assertEquals($expectedResponse, $response->getContent());
}
示例2: testRender
public function testRender()
{
$view = $this->createView();
$view->setTemplateIdentifier('path/to/template.html.twig');
$this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(MVCEvents::PRE_CONTENT_VIEW, $this->isInstanceOf('\\eZ\\Publish\\Core\\MVC\\Symfony\\Event\\PreContentViewEvent'));
$this->templateEngineMock->expects($this->once())->method('render')->with('path/to/template.html.twig', $view->getParameters());
$this->renderer->render($view);
}
示例3: testRenderForContentTemplateOverride
/**
* @dataProvider renderForContentTestProvider
*
* @param ContentInfo $contentInfo
* @param Request $request
* @param array $options
* @param array $customOptions
*/
public function testRenderForContentTemplateOverride(ContentInfo $contentInfo, Request $request, array $options, array $customOptions = array())
{
$renderedComments = "I'm a comments thread for {$contentInfo->id}!";
$template = 'override.html.twig';
$this->templateEngine->expects($this->once())->method('render')->with($template, $customOptions + $options)->will($this->returnValue($renderedComments));
$this->assertSame($renderedComments, $this->getCommentsProvider($this->templateEngine, $template)->renderForContent($contentInfo, $request, $customOptions + array('template' => $template)));
}
示例4: testSetsHTMLPart
/**
* Test if sender is set on Swift_Message without a name
*/
public function testSetsHTMLPart()
{
$this->templateEngine->expects($this->any())->method('render')->willReturn($this->messageBody);
$this->message->expects($this->atLeastOnce())->method('addPart')->with($this->equalTo($this->messageBody), $this->equalTo('text/html'));
$this->addDefaultSender();
$this->defaultSend();
}
示例5: testRenderWidgetGroup
public function testRenderWidgetGroup()
{
$this->widgetsHandler->addWidget($this->getWidget('group-widget-1', 'SuluTestBundle:widget:widget1.html.twig', array('test' => '1')), 'group-widget-1');
$this->widgetsHandler->addWidget($this->getWidget('group-widget-3', 'SuluTestBundle:widget:widget3.html.twig', array('test' => '3')), 'group-widget-3');
$this->widgetsHandler->addWidget($this->getWidget('group-widget-2', 'SuluTestBundle:widget:widget2.html.twig', array('test' => '2')), 'group-widget-2');
$param = false;
$template = false;
$this->templateEngine->expects($this->any())->method('render')->will($this->returnCallback(function ($t, $p) use(&$template, &$param) {
$param = $p;
$template = $t;
return true;
}));
$this->assertTrue($this->widgetsHandler->renderWidgetGroup('test-group', array('testParam' => 'super')));
$this->assertNotFalse($param);
$this->assertNotFalse($template);
$this->assertEquals('SuluAdminBundle:Widgets:widgets.html.twig', $template);
$this->assertEquals(array('widgets' => array(array('name' => 'group-widget-1', 'template' => 'SuluTestBundle:widget:widget1.html.twig', 'data' => array('test' => 1)), array('name' => 'group-widget-1', 'template' => 'SuluTestBundle:widget:widget1.html.twig', 'data' => array('test' => 1)), array('name' => 'group-widget-3', 'template' => 'SuluTestBundle:widget:widget3.html.twig', 'data' => array('test' => 3)), array('name' => 'group-widget-2', 'template' => 'SuluTestBundle:widget:widget2.html.twig', 'data' => array('test' => 2))), 'parameters' => array('testParam' => 'super')), $param);
}
示例6: testGetEmailBody
public function testGetEmailBody()
{
$emailEntity = new Email();
$templatePath = 'template_path';
$body = 'body';
$this->emailCacheManager->expects($this->once())->method('ensureEmailBodyCached')->with($emailEntity);
$this->templating->expects($this->once())->method('render')->with($templatePath, ['email' => $emailEntity])->willReturn($body);
$result = $this->helper->getEmailBody($emailEntity, $templatePath);
$this->assertEquals($body, $result);
}
示例7: testGenerateResponseWithCustomLayout
/**
* @dataProvider generateResponseWithCustomLayoutProvider
*/
public function testGenerateResponseWithCustomLayout($customLayout, $content)
{
$contentWithLayout = "<div id=\"i-am-a-twig-layout\">{$content}</div>";
$moduleResult = array('content' => $content, 'errorCode' => 200);
$this->configResolver->expects($this->any())->method('getParameter')->will($this->returnValueMap(array(array('module_default_layout', 'ezpublish_legacy', null, $customLayout), array('legacy_mode', null, null, false))));
$this->templateEngine->expects($this->once())->method('render')->with($customLayout, array('module_result' => $moduleResult))->will($this->returnValue($contentWithLayout));
$manager = new LegacyResponseManager($this->templateEngine, $this->configResolver);
$kernelResult = new ezpKernelResult($content, array('module_result' => $moduleResult));
$response = $manager->generateResponseFromModuleResult($kernelResult);
$this->assertInstanceOf('eZ\\Bundle\\EzPublishLegacyBundle\\LegacyResponse', $response);
$this->assertSame($contentWithLayout, $response->getContent());
$this->assertSame($moduleResult['errorCode'], $response->getStatusCode());
$this->assertSame($moduleResult, $response->getModuleResult());
}
示例8: testRenderLocationWithClosure
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);
}