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


PHP Twig_Environment::expects方法代码示例

本文整理汇总了PHP中Twig_Environment::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Environment::expects方法的具体用法?PHP Twig_Environment::expects怎么用?PHP Twig_Environment::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_Environment的用法示例。


在下文中一共展示了Twig_Environment::expects方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $this->renderer = new DataBlockRenderer();
     $this->factory = Forms::createFormFactoryBuilder()->addTypeExtension(new DataBlockExtension())->getFormFactory();
     $this->twig = $this->getMockBuilder('\\Twig_Environment')->disableOriginalConstructor()->getMock();
     $this->twig->expects($this->any())->method('render')->will($this->returnValue(null));
     $this->twig->expects($this->any())->method('getLoader')->will($this->returnValue($this->getMockForAbstractClass('\\Twig_LoaderInterface')));
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:DataBlockRendererTest.php

示例2: setUp

 public function setUp()
 {
     $timezone = new DateTimeZone(date_default_timezone_get());
     $coreExtension = $this->getMock('Twig_Extension_Core');
     $coreExtension->expects($this->any())->method('getTimezone')->will($this->returnValue($timezone));
     $this->env = $this->getMock('Twig_Environment');
     $this->env->expects($this->any())->method('getExtension')->with('core')->will($this->returnValue($coreExtension));
 }
开发者ID:teraone,项目名称:twig-strftime-extension,代码行数:8,代码来源:StrftimeExtensionTest.php

示例3: setUp

 protected function setUp()
 {
     $this->loader = $this->getMockBuilder(MailLoaderInterface::class)->getMock();
     $this->twig = $this->getMockBuilder(\Twig_Environment::class)->getMock();
     $this->twigTemplate = $this->getMockBuilder(\Twig_Template::class)->disableOriginalConstructor()->getMock();
     $this->dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
     $this->templater = new MailTemplater($this->loader, $this->twig, $this->dispatcher);
     $this->twig->expects($this->any())->method('createTemplate')->will($this->returnValue($this->twigTemplate));
     $this->twig->expects($this->any())->method('loadTemplate')->will($this->returnValue($this->twigTemplate));
 }
开发者ID:sonatra,项目名称:SonatraMailerBundle,代码行数:10,代码来源:MailTemplaterTest.php

示例4: testItCanWrapATwigTemplateIntoAResponse

 public function testItCanWrapATwigTemplateIntoAResponse()
 {
     $name = 'template_name';
     $context = ['foo' => 'bar'];
     $status = 400;
     $headers = ['baz' => 'bim'];
     $this->twig->expects($this->once())->method('render')->with($name, $context)->willReturn('foo content');
     $response = $this->sut->renderResponse($name, $context, $status, $headers);
     $this->assertInstanceOf(Response::class, $response);
     $this->assertSame(400, $response->getStatusCode());
     $this->assertSame('foo content', $response->getContent());
     $this->assertTrue($response->headers->contains('baz', 'bim'));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:13,代码来源:ControllerTest.php

示例5: mockTwigEnvironment

 protected function mockTwigEnvironment()
 {
     $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->getMock();
     $this->twigEnvironment->expects($this->any())->method('loadTemplate')->will($this->returnValue('loadedTemplate'));
     $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($this->getMock('\\Twig_LoaderInterface')));
     return $this->twigEnvironment;
 }
开发者ID:MTyassine,项目名称:jciperformsystem,代码行数:7,代码来源:TemplateManagerTest.php

示例6: testNotifyWithEmptyAuthor

 public function testNotifyWithEmptyAuthor()
 {
     $ticketUniqueId = UniqueId::generate();
     $reporter = new UserAdapter(1, UserAdapter::TYPE_DIAMANTE);
     $assignee = new User();
     $assignee->setId(2);
     $assignee->setEmail('assignee@host.com');
     $author = null;
     $branch = new Branch('KEY', 'Name', 'Description');
     $ticket = new Ticket($ticketUniqueId, new TicketSequenceNumber(1), 'Subject', 'Description', $branch, $reporter, $assignee, new Source(Source::WEB), new Priority(Priority::PRIORITY_MEDIUM), new Status(Status::NEW_ONE));
     $notification = new TicketNotification((string) $ticketUniqueId, $author, 'Header', 'Subject', new \ArrayIterator(array('key' => 'value')), array('file.ext'));
     $message = new \Swift_Message();
     $this->watchersService->expects($this->once())->method('getWatchers')->will($this->returnValue([new WatcherList($ticket, 'diamante_1')]));
     $this->diamanteUserRepository->expects($this->exactly(2))->method('get')->with(1)->will($this->returnValue($this->diamanteUser));
     $this->configManager->expects($this->once())->method('get')->will($this->returnValue('test@gmail.com'));
     $this->nameFormatter->expects($this->once())->method('format')->with($this->diamanteUser)->will($this->returnValue('First Last'));
     $this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
     $this->ticketRepository->expects($this->once())->method('getByUniqueId')->with($ticketUniqueId)->will($this->returnValue($ticket));
     $this->templateResolver->expects($this->any())->method('resolve')->will($this->returnValueMap(array(array($notification, TemplateResolver::TYPE_TXT, 'txt.template.html'), array($notification, TemplateResolver::TYPE_HTML, 'html.template.html'))));
     $optionsConstraint = $this->logicalAnd($this->arrayHasKey('changes'), $this->arrayHasKey('attachments'), $this->arrayHasKey('user'), $this->arrayHasKey('header'), $this->contains($notification->getChangeList()), $this->contains($notification->getAttachments()), $this->contains('First Last'), $this->contains($notification->getHeaderText()));
     $this->twig->expects($this->at(0))->method('render')->with('txt.template.html', $optionsConstraint)->will($this->returnValue('Rendered TXT template'));
     $this->twig->expects($this->at(1))->method('render')->with('html.template.html', $optionsConstraint)->will($this->returnValue('Rendered HTML template'));
     $this->mailer->expects($this->once())->method('send')->with($this->logicalAnd($this->isInstanceOf('\\Swift_Message'), $this->callback(function (\Swift_Message $other) use($notification) {
         $to = $other->getTo();
         return false !== strpos($other->getSubject(), $notification->getSubject()) && false !== strpos($other->getSubject(), 'KEY-1') && false !== strpos($other->getBody(), 'Rendered TXT template') && array_key_exists('reporter@host.com', $to) && $other->getHeaders()->has('References') && false !== strpos($other->getHeaders()->get('References'), 'id_1@host.com') && false !== strpos($other->getHeaders()->get('References'), 'id_2@host.com');
     })));
     $this->messageReferenceRepository->expects($this->once())->method('findAllByTicket')->with($ticket)->will($this->returnValue(array(new MessageReference('id_1@host.com', $ticket), new MessageReference('id_2@host.com', $ticket))));
     $this->messageReferenceRepository->expects($this->once())->method('store')->with($this->logicalAnd($this->isInstanceOf('\\Diamante\\DeskBundle\\Model\\Ticket\\EmailProcessing\\MessageReference')));
     $notifier = new EmailNotifier($this->container, $this->twig, $this->mailer, $this->templateResolver, $this->ticketRepository, $this->messageReferenceRepository, $this->userService, $this->nameFormatter, $this->diamanteUserRepository, $this->configManager, $this->oroUserManager, $this->watchersService, $this->senderHost);
     $notifier->notify($notification);
 }
开发者ID:northdakota,项目名称:DiamanteDeskBundle,代码行数:31,代码来源:EmailNotifierTest.php

示例7: testRenderFragmentWithoutUser

 public function testRenderFragmentWithoutUser()
 {
     $windowState = $this->createWindowState();
     $this->environment->expects($this->never())->method($this->anything());
     $this->stateManager->expects($this->once())->method('deleteWindowsState')->willThrowException(new AccessDeniedException());
     $this->assertEquals('', $this->extension->renderFragment($this->environment, $windowState));
     $this->assertFalse($windowState->isRenderedSuccessfully());
 }
开发者ID:ramunasd,项目名称:platform,代码行数:8,代码来源:WindowsExtensionTest.php

示例8: testSendConfirmationEmail

 public function testSendConfirmationEmail()
 {
     $email = 'test@email.com';
     $activationHash = md5(time());
     $fromEmail = 'from@email.com';
     $htmlTemplate = 'html.tpl';
     $txtTemplate = 'txt.tpl';
     $registrationMailer = new RegistrationMailer($this->twig, $this->mailer, $fromEmail, $htmlTemplate, $txtTemplate);
     $confirmation = new \Swift_Message();
     $renderedHtmlTpl = 'rendered html';
     $renderedTxtTpl = 'rendered txt';
     $this->twig->expects($this->at(0))->method('render')->with($txtTemplate)->will($this->returnValue($renderedTxtTpl));
     $this->twig->expects($this->at(1))->method('render')->with($htmlTemplate)->will($this->returnValue($renderedHtmlTpl));
     $this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($confirmation));
     $this->mailer->expects($this->once())->method('send')->with($this->logicalAnd($this->isInstanceOf('\\Swift_Message'), $this->callback(function (\Swift_Message $other) use($email, $renderedTxtTpl, $fromEmail) {
         return $other->getSubject() == 'Confirmation' && $other->getBody() == $renderedTxtTpl && array_key_exists($email, $other->getTo()) && array_key_exists($fromEmail, $other->getReplyTo());
     })));
     $registrationMailer->sendConfirmationEmail($email, $activationHash);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:19,代码来源:RegistrationMailerTest.php

示例9: mockTwigEnvironment

 protected function mockTwigEnvironment()
 {
     $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $this->twigEnvironment->expects($this->any())->method('loadTemplate')->will($this->returnValue('loadedTemplate'));
     if (interface_exists('\\Twig_SourceContextLoaderInterface')) {
         $loader = $this->getMock('\\Twig_SourceContextLoaderInterface');
     } else {
         $loader = $this->getMock('\\Twig_LoaderInterface');
     }
     $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));
     return $this->twigEnvironment;
 }
开发者ID:blazarecki,项目名称:symfony,代码行数:12,代码来源:TemplateManagerTest.php

示例10: testRenderGlobalAction

 /**
  * @dataProvider renderProvider
  */
 public function testRenderGlobalAction($gridTemplate = null, $rendererTemplate = null)
 {
     $template = 'global_action';
     if ($rendererTemplate !== null) {
         $this->renderer = new Renderer($this->twig, $this->actionRenderer, $this->columnRenderer, $this->sorterRenderer, [$template => $rendererTemplate]);
     }
     $view = $this->createGridViewMock();
     $view->expects($this->once())->method('getDefinition')->will($this->returnValue($grid = $this->createGridMock()));
     $grid->expects($this->once())->method('hasOption')->with($this->identicalTo($option = $template . '_template'))->will($this->returnValue($gridTemplate !== null));
     $grid->expects($gridTemplate !== null ? $this->once() : $this->never())->method('getOption')->with($this->identicalTo($option))->will($this->returnValue($gridTemplate));
     $this->actionRenderer->expects($this->once())->method('render')->with($this->identicalTo($view), $this->identicalTo($action = $this->createActionMock()), $this->isNull())->will($this->returnValue($value = 'value'));
     $this->twig->expects($this->once())->method('render')->with($this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/' . $template . '.html.twig')), $this->identicalTo(['action' => $action, 'value' => $value, 'grid' => $view]))->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->renderer->renderGlobalAction($view, $action));
 }
开发者ID:blazarecki,项目名称:lug,代码行数:17,代码来源:RendererTest.php

示例11: testSendMessageWithNoBodyHtmlBlock

 /**
  * Tests the sendMessage method with no body_html block.
  */
 public function testSendMessageWithNoBodyHtmlBlock()
 {
     $this->twig->expects($this->once())->method('loadTemplate')->will($this->returnValue($this->template));
     $contact = new Contact();
     $this->template->expects($this->exactly(3))->method('renderBlock')->withConsecutive(array($this->equalTo('subject'), $this->equalTo(array('contact' => $contact))), array($this->equalTo('body_text'), $this->equalTo(array('contact' => $contact))), array($this->equalTo('body_html'), $this->equalTo(array('contact' => $contact))))->willReturnOnConsecutiveCalls('', 'Body text', '');
     $message = $this->getMockBuilder('\\Swift_Message')->disableOriginalConstructor()->getMock();
     $message->expects($this->once())->method('setSubject')->willReturnSelf();
     $message->expects($this->once())->method('setFrom')->willReturnSelf();
     $message->expects($this->once())->method('setTo')->willReturnSelf();
     $message->expects($this->once())->method('setBody')->with($this->equalTo('Body text'));
     $message->expects($this->never())->method('addPart');
     $this->serviceMailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
     $this->mailer->expects($this->once())->method('send')->with($this->equalTo($message));
     $this->serviceMailer->sendMessage($contact);
 }
开发者ID:rkueny,项目名称:ContactBundle,代码行数:18,代码来源:TwigSwiftMailerTest.php

示例12: testNotify

 public function testNotify()
 {
     $author = new ApiUser('reporter@host.com', 'password');
     $notification = new UserNotification($author, 'Header');
     $format = '%prefix% %first_name% %middle_name% %last_name% %suffix%';
     $message = new \Swift_Message();
     $this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
     $this->configManager->expects($this->once())->method('get')->will($this->returnValue('Mike The Bot'));
     $this->nameFormatter->expects($this->any())->method('format')->with($this->diamanteUser)->will($this->returnValue('First Last'));
     $this->userService->expects($this->once())->method('verifyDiamanteUserExists')->with($this->equalTo($author->getEmail()))->will($this->returnValue(1));
     $this->userService->expects($this->once())->method('getByUser')->with($this->equalTo(new UserAdapter(1, UserAdapter::TYPE_DIAMANTE)))->will($this->returnValue($this->diamanteUser));
     $this->nameFormatter->expects($this->once())->method('getNameFormat')->will($this->returnValue($format));
     $this->templateResolver->expects($this->any())->method('resolve')->will($this->returnValueMap(array(array($notification, TemplateResolver::TYPE_TXT, 'txt.template.html'), array($notification, TemplateResolver::TYPE_HTML, 'html.template.html'))));
     $optionsConstraint = $this->logicalAnd($this->arrayHasKey('user'), $this->arrayHasKey('header'), $this->contains('First  Last'), $this->contains($notification->getHeaderText()));
     $this->twig->expects($this->at(0))->method('render')->with('txt.template.html', $optionsConstraint)->will($this->returnValue('Rendered TXT template'));
     $this->twig->expects($this->at(1))->method('render')->with('html.template.html', $optionsConstraint)->will($this->returnValue('Rendered HTML template'));
     $this->mailer->expects($this->once())->method('send')->with($this->logicalAnd($this->isInstanceOf('\\Swift_Message'), $this->callback(function (\Swift_Message $other) use($notification) {
         $to = $other->getTo();
         return false !== strpos($other->getBody(), 'Rendered TXT template') && array_key_exists('reporter@host.com', $to);
     })));
     $notifier = new EmailNotifier($this->twig, $this->mailer, $this->templateResolver, $this->userService, $this->nameFormatter, $this->configManager, $this->senderEmail);
     $notifier->notify($notification);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:23,代码来源:EmailNotifierTest.php

示例13: testRender

 public function testRender()
 {
     $this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue($boolean = true));
     $this->twig->expects($this->once())->method('render')->with($this->identicalTo($this->template), $this->identicalTo(array_merge($context = ['foo' => 'bar'], ['column' => $column = $this->createColumnMock(), 'data' => $boolean])))->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->type->render($data, ['column' => $column, 'path' => $path, 'template' => $this->template, 'context' => $context]));
 }
开发者ID:blazarecki,项目名称:lug,代码行数:6,代码来源:BooleanTypeTest.php


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