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


PHP EventDispatcher::expects方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->requestStack = new RequestStack();
     $request = new Request();
     $this->requestStack->push($request);
     $this->session = new Session(new MockArraySessionStorage());
     $request->setSession($this->session);
     $this->dispatcher = new EventDispatcher();
     $translator = new Translator($this->getMock('\\Symfony\\Component\\DependencyInjection\\ContainerInterface'));
     $token = new TokenProvider($this->requestStack, $translator, 'test');
     $this->dispatcher->addSubscriber(new \Thelia\Action\Cart($this->requestStack, $token));
     $this->session->setSessionCart(null);
     $request->setSession($this->session);
     /** @var \Thelia\Action\Cart  cartAction */
     $this->cartAction = new \Thelia\Action\Cart($this->requestStack, new TokenProvider($this->requestStack, $translator, 'baba au rhum'));
     $this->dispatcherNull = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', array(), array(), '', true, true, true, false);
     $this->dispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($type, $event) {
         if ($type == TheliaEvents::CART_RESTORE_CURRENT) {
             $this->cartAction->restoreCurrentCart($event, null, $this->dispatcher);
         } elseif ($type == TheliaEvents::CART_CREATE_NEW) {
             $this->cartAction->createEmptyCart($event, null, $this->dispatcher);
         }
     }));
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:25,代码来源:SessionTest.php

示例2: testProcess

 public function testProcess()
 {
     $env = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
     $formView = $this->getMockBuilder('Symfony\\Component\\Form\\FormView')->disableOriginalConstructor()->getMock();
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::BEFORE_UPDATE_FORM_RENDER, $this->isInstanceOf('Oro\\Bundle\\UIBundle\\Event\\BeforeFormRenderEvent'));
     $formData = array("test");
     $this->assertEquals($formData, $this->extension->process($env, $formData, $formView));
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:FormExtensionTest.php

示例3: testCanWithListener

 public function testCanWithListener()
 {
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with('finite.test_transition', $this->isInstanceOf('Finite\\Event\\TransitionEvent'));
     $this->dispatcher->expects($this->at(2))->method('dispatch')->with('finite.test_transition.t23', $this->callback(function ($event) {
         $event->reject();
         return $event instanceof \Finite\Event\TransitionEvent;
     }));
     $this->initialize();
     $this->assertFalse($this->object->can('t34'));
     $this->assertFalse($this->object->can('t23'));
 }
开发者ID:Aasit,项目名称:DISCOUNT--SRV-I,代码行数:11,代码来源:ListenableStateMachineTest.php

示例4: testMatchedRequestDispatchesEvent

 public function testMatchedRequestDispatchesEvent()
 {
     $matchResult = new MatchResult(true, $event = new NotificationEvent('my-event'));
     /** @var RequestInterface $request */
     $request = self::createMock(RequestInterface::class);
     /** @var ResponseInterface $response */
     $response = self::createMock(ResponseInterface::class);
     $this->matcher->expects(self::any())->method('match')->willReturn($matchResult);
     $this->dispatcher->expects(self::once())->method('dispatch')->with($event->getName(), $event);
     $this->middleware->__invoke($request, $response);
 }
开发者ID:jeremygiberson,项目名称:psr7-push-notification-middleware,代码行数:11,代码来源:AbstractMiddlewareTest.php

示例5: testCloseJobDoesNotCreateMoreThanAllowedRetries

 public function testCloseJobDoesNotCreateMoreThanAllowedRetries()
 {
     $a = new Job('a');
     $a->setMaxRetries(2);
     $a->setState('running');
     $this->em->persist($a);
     $this->em->flush();
     $this->dispatcher->expects($this->at(0))->method('dispatch')->with('jms_job_queue.job_state_change', new StateChangeEvent($a, 'failed'));
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with('jms_job_queue.job_state_change', new \PHPUnit_Framework_Constraint_Not($this->equalTo(new StateChangeEvent($a, 'failed'))));
     $this->dispatcher->expects($this->at(2))->method('dispatch')->with('jms_job_queue.job_state_change', new \PHPUnit_Framework_Constraint_Not($this->equalTo(new StateChangeEvent($a, 'failed'))));
     $this->assertCount(0, $a->getRetryJobs());
     $this->repo->closeJob($a, 'failed');
     $this->assertEquals('running', $a->getState());
     $this->assertCount(1, $a->getRetryJobs());
     $a->getRetryJobs()->first()->setState('running');
     $this->repo->closeJob($a->getRetryJobs()->first(), 'failed');
     $this->assertCount(2, $a->getRetryJobs());
     $this->assertEquals('failed', $a->getRetryJobs()->first()->getState());
     $this->assertEquals('running', $a->getState());
     $a->getRetryJobs()->last()->setState('running');
     $this->repo->closeJob($a->getRetryJobs()->last(), 'terminated');
     $this->assertCount(2, $a->getRetryJobs());
     $this->assertEquals('terminated', $a->getRetryJobs()->last()->getState());
     $this->assertEquals('terminated', $a->getState());
     $this->em->clear();
     $reloadedA = $this->em->find('JMSJobQueueBundle:Job', $a->getId());
     $this->assertCount(2, $reloadedA->getRetryJobs());
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:28,代码来源:JobRepositoryTest.php

示例6: testSave

 /**
  * Test saving settings
  */
 public function testSave()
 {
     $settings = array('oro_user___level' => array('value' => 50));
     $removed = array('oro_user___greeting' => array('value' => 'new value'));
     $object = $this->getMock('Oro\\Bundle\\ConfigBundle\\Config\\ConfigManager', array('calculateChangeSet', 'reload', 'get'), array($this->ed, $this->om, new ConfigDefinitionImmutableBag($this->settings)));
     $changes = array($settings, $removed);
     $object->expects($this->once())->method('calculateChangeSet')->with($this->equalTo($settings))->will($this->returnValue($changes));
     $object->expects($this->once())->method('reload');
     $configMock = $this->getMock('Oro\\Bundle\\ConfigBundle\\Entity\\Config');
     $configMock->expects($this->once())->method('getOrCreateValue')->will($this->returnValue(new ConfigValue()));
     $configMock->expects($this->once())->method('getValues')->will($this->returnValue(new ArrayCollection()));
     $valueRepository = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Entity\\Repository\\ConfigValueRepository')->disableOriginalConstructor()->getMock();
     $repository = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Entity\\Repository\\ConfigRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('getByEntity')->with('app', 0)->will($this->returnValue($configMock));
     $this->om->expects($this->at(0))->method('getRepository')->will($this->returnValue($valueRepository));
     $this->om->expects($this->at(1))->method('getRepository')->will($this->returnValue($repository));
     $this->om->expects($this->once())->method('persist');
     $this->om->expects($this->once())->method('flush');
     $object->expects($this->exactly(3))->method('get');
     $this->ed->expects($this->once())->method('dispatch')->with($this->equalTo('oro_config.update_after'), $this->isInstanceOf('Oro\\Bundle\\ConfigBundle\\Event\\ConfigUpdateEvent'));
     $object->save($settings);
 }
开发者ID:xamin123,项目名称:platform,代码行数:25,代码来源:ConfigManagerTest.php

示例7: testShouldDispatchProcessEvent

 public function testShouldDispatchProcessEvent()
 {
     $this->dispatcherMock->expects($this->at(0))->method('dispatch')->with($this->equalTo(CommandEvents::RUN_TESTS_PROCESS), $this->isInstanceOf(RunTestsProcessEvent::class));
     $this->creator->createFromFiles($this->findDummyTests(), [], ['bar', 'foo']);
 }
开发者ID:jirinovak,项目名称:steward,代码行数:5,代码来源:ProcessSetCreatorTest.php


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