當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。