当前位置: 首页>>代码示例>>PHP>>正文


PHP EngineInterface::expects方法代码示例

本文整理汇总了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());
 }
开发者ID:damonsson,项目名称:SeoBundle,代码行数:8,代码来源:SitemapControllerTest.php

示例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);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:8,代码来源:TemplateRendererTest.php

示例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)));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:15,代码来源:TemplateBasedProviderTest.php

示例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();
 }
开发者ID:silktide,项目名称:templated-emailer,代码行数:10,代码来源:TemplatedMailerTest.php

示例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);
 }
开发者ID:eiannone,项目名称:SuluAdminBundle,代码行数:18,代码来源:WidgetsHandlerTest.php

示例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);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:EmailModelBuilderHelperTest.php

示例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());
 }
开发者ID:masev,项目名称:ezpublish-kernel,代码行数:17,代码来源:LegacyResponseManagerTest.php

示例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);
 }
开发者ID:emodric,项目名称:ezpublish-kernel,代码行数:24,代码来源:ViewManagerTest.php


注:本文中的Symfony\Component\Templating\EngineInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。