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


PHP EventDispatcherInterface::expects方法代码示例

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


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

示例1: testGetFields

 /**
  * @param array $fields
  * @param array $configValues
  * @param array $expected
  *
  * @dataProvider fieldsDataProvider
  */
 public function testGetFields(array $fields, array $configValues, array $expected)
 {
     $entity = new \StdClass();
     foreach ($fields as $field) {
         /** @var ConfigInterface $field */
         $fieldId = $field->getId();
         /** @var FieldConfigId $fieldId */
         $fieldName = $fieldId->getFieldName();
         $entity->{$fieldName} = $fieldName;
     }
     $this->configProvider->expects($this->once())->method('filter')->will($this->returnValue($fields));
     $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $this->configProvider->expects($this->any())->method('getConfigById')->will($this->returnValue($config));
     foreach ($configValues as $key => $configValue) {
         $config->expects($this->at($key))->method('get')->will($this->returnCallback(function ($value, $strict, $default) use($configValue) {
             if (!is_null($configValue)) {
                 return $configValue;
             }
             return $default;
         }));
     }
     $this->dispatcher->expects($this->exactly(sizeof($fields)))->method('dispatch');
     $rows = $this->extension->getFields($entity);
     $this->assertEquals(json_encode($expected), json_encode($rows));
 }
开发者ID:northdakota,项目名称:platform,代码行数:32,代码来源:DynamicFieldsExtensionTest.php

示例2: testFixtureManager

 public function testFixtureManager()
 {
     $this->loader->expects($this->once())->method('load')->will($this->returnValue(new FixtureCollection()));
     $this->executor->expects($this->once())->method('execute');
     $this->persister->expects($this->once())->method('flush');
     $this->eventDispatcher->expects($this->exactly(5))->method('dispatch');
     $this->fixtureManager->load(null);
 }
开发者ID:davidbadura,项目名称:fixtures,代码行数:8,代码来源:FixtureManagerTest.php

示例3: setUpDisplayVariant

 /**
  * Sets up a display variant plugin for testing.
  *
  * @param array $configuration
  *   An array of plugin configuration.
  * @param array $definition
  *   The plugin definition array.
  *
  * @return \Drupal\block\Plugin\DisplayVariant\BlockPageVariant|\PHPUnit_Framework_MockObject_MockObject
  *   A mocked display variant plugin.
  */
 public function setUpDisplayVariant($configuration = array(), $definition = array())
 {
     $this->blockRepository = $this->getMock('Drupal\\block\\BlockRepositoryInterface');
     $this->blockViewBuilder = $this->getMock('Drupal\\Core\\Entity\\EntityViewBuilderInterface');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->dispatcher->expects($this->any())->method('dispatch')->willReturnArgument(1);
     return $this->getMockBuilder('Drupal\\block\\Plugin\\DisplayVariant\\BlockPageVariant')->setConstructorArgs(array($configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, $this->dispatcher, ['config:block_list']))->setMethods(array('getRegionNames'))->getMock();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:19,代码来源:BlockPageVariantTest.php

示例4: 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

示例5: getEventMock

 /**
  * @return PHPUnit_Framework_MockObject_MockObject|$class
  */
 protected function getEventMock($class)
 {
     if (!isset($this->eventMock)) {
         $this->eventMock = $this->getMockBuilder($class)->disableOriginalConstructor()->getMock();
         $this->eventMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->getRequestMock()));
     }
     return $this->eventMock;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:11,代码来源:EventListenerTest.php

示例6: testCreate

 public function testCreate()
 {
     $this->builder->expects($this->once())->method('getName')->will($this->returnValue($name = 'name'));
     $this->factory->expects($this->once())->method('createItem')->with($this->identicalTo($name))->will($this->returnValue($item = $this->createItemMock()));
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->identicalTo(MenuBuilderEvents::BUILD), $this->callback(function (MenuBuilderEvent $event) use($item) {
         return $event->getFactory() === $this->factory && $event->getItem() === $item;
     }));
     $this->assertSame($item, $this->builder->create());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:9,代码来源:MenuBuilderTest.php

示例7: testCreateDefaultPluginInstanceWithDefaultPluginInstance

 /**
  * @covers ::createDefaultPluginInstance
  */
 public function testCreateDefaultPluginInstanceWithDefaultPluginInstance()
 {
     $default_plugin_instance = $this->getMock(PluginInspectionInterface::class);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(PluginEvents::RESOLVE_DEFAULT_PLUGIN, $this->isInstanceOf(ResolveDefaultPlugin::class))->willReturnCallback(function ($event_name, ResolveDefaultPlugin $event) use($default_plugin_instance) {
         $event->setDefaultPluginInstance($default_plugin_instance);
     });
     $plugin_type = $this->getMock(PluginTypeInterface::class);
     $this->assertSame($default_plugin_instance, $this->sut->createDefaultPluginInstance($plugin_type));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:EventBasedDefaultPluginResolverTest.php

示例8: setUp

 public function setUp()
 {
     $user = $this->createMock('FOS\\UserBundle\\Model\\UserInterface');
     $user->expects($this->once())->method('isEnabled')->willReturn(true);
     $response = $this->createMock('Symfony\\Component\\HttpFoundation\\Response');
     $request = $this->createMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->event = new FilterUserResponseEvent($user, $request, $response);
     $this->eventDispatcher = $this->createMock('Symfony\\Component\\EventDispatcher\\EventDispatcher');
     $this->eventDispatcher->expects($this->once())->method('dispatch');
     $loginManager = $this->createMock('FOS\\UserBundle\\Security\\LoginManagerInterface');
     $this->listener = new AuthenticationListener($loginManager, self::FIREWALL_NAME);
 }
开发者ID:ismailbaskin,项目名称:FOSUserBundle,代码行数:12,代码来源:AuthenticationListenerTest.php

示例9: testConsume

 public function testConsume()
 {
     $queue = 'foobar';
     $message = $this->createMock(MessageInterface::class);
     $iterator = new TestIterator([$message]);
     $this->backendProvider->expects($this->any())->method('getBackend')->with($queue)->willReturn($this->backend);
     $this->backend->expects($this->any())->method('getIterator')->willReturn($iterator);
     $this->backend->expects($this->once())->method('handle')->with($message, $this->notificationDispatcher);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(IterateEvent::EVENT_NAME, new IterateEvent($this->backend->getIterator(), $this->backend, $message));
     // the $iterator does not pop elements so we have to make sure ->tick() does not iterate over the same array multiple times
     $this->subject->consume($queue, ['stop-when-empty' => true]);
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:12,代码来源:ConsumerAdapterTest.php

示例10: testProcessValidData

 public function testProcessValidData()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('persist')->with($this->entity);
     $this->em->expects($this->once())->method('flush');
     $this->dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(ChannelSaveEvent::EVENT_NAME), $this->isInstanceOf('OroCRM\\Bundle\\ChannelBundle\\Event\\ChannelSaveEvent'));
     $this->assertTrue($this->handler->process($this->entity));
 }
开发者ID:dairdr,项目名称:crm,代码行数:12,代码来源:ChannelHandlerTest.php

示例11: testDispatchFormEvent

 public function testDispatchFormEvent()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|FormInterface $form */
     $form = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $form->expects($this->once())->method('getName')->will($this->returnValue('form_name'));
     $data = [];
     $event = new FormProcessEvent($form, $data);
     $eventName = 'test_event_name';
     $this->eventDispatcher->expects($this->exactly(2))->method('dispatch');
     $this->eventDispatcher->expects($this->at(0))->method('dispatch')->with($eventName, $event);
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with($eventName . '.form_name', $event);
     $this->immutableDispatcher->dispatch($eventName, $event);
 }
开发者ID:snorchel,项目名称:platform,代码行数:13,代码来源:EventDispatcherTest.php

示例12: testHandle

 public function testHandle()
 {
     $this->firewall->expects($this->once())->method('authorize')->with($this->identicalTo($headers = ['X-Hub-Signature' => 'sha1=52b582138706ac0c597c315cfc1a1bf177408a4d']), $this->identicalTo($body = '{"foo":"bar"}'))->will($this->returnValue(true));
     $process = $this->createProcessMock();
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->identicalTo(WebhookEvents::HOOK), $this->callback(function ($event) use($body, $process) {
         if (!$event instanceof WebhookEvent || $event->getPayload() !== json_decode($body, true)) {
             return false;
         }
         $event->addProcess($process);
         return true;
     }));
     $this->processProducer->expects($this->once())->method('publish')->with($this->identicalTo($process));
     $this->handler->handle($headers, $body);
 }
开发者ID:php-lug,项目名称:webhook,代码行数:14,代码来源:WebhookHandlerTest.php

示例13: testRebuildWithProviderBasedRoutes

 /**
  * Tests the rebuild with routes provided by a callback.
  *
  * @see \Drupal\Core\Routing\RouteBuilder::rebuild()
  */
 public function testRebuildWithProviderBasedRoutes()
 {
     $this->lock->expects($this->once())->method('acquire')->with('router_rebuild')->will($this->returnValue(TRUE));
     $this->yamlDiscovery->expects($this->once())->method('findAll')->will($this->returnValue(array('test_module' => array('route_callbacks' => array('\\Drupal\\Tests\\Core\\Routing\\TestRouteSubscriber::routesFromArray', 'test_module.route_service:routesFromCollection')))));
     $container = new ContainerBuilder();
     $container->set('test_module.route_service', new TestRouteSubscriber());
     $this->controllerResolver->expects($this->any())->method('getControllerFromDefinition')->will($this->returnCallback(function ($controller) use($container) {
         $count = substr_count($controller, ':');
         if ($count == 1) {
             list($service, $method) = explode(':', $controller, 2);
             $object = $container->get($service);
         } else {
             list($class, $method) = explode('::', $controller, 2);
             $object = new $class();
         }
         return array($object, $method);
     }));
     $route_collection_filled = new RouteCollection();
     $route_collection_filled->add('test_route.1', new Route('/test-route/1'));
     $route_collection_filled->add('test_route.2', new Route('/test-route/2'));
     $route_build_event = new RouteBuildEvent($route_collection_filled);
     // Ensure that the alter routes events are fired.
     $this->dispatcher->expects($this->at(0))->method('dispatch')->with(RoutingEvents::DYNAMIC, $route_build_event);
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with(RoutingEvents::ALTER, $route_build_event);
     // Ensure that the routes are set to the dumper and dumped.
     $this->dumper->expects($this->at(0))->method('addRoutes')->with($route_collection_filled);
     $this->dumper->expects($this->at(1))->method('dump');
     $this->assertTrue($this->routeBuilder->rebuild());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:RouteBuilderTest.php

示例14: testEventDispatching

 /**
  * @dataProvider eventDataProvider
  *
  * @param Integration      $entity
  * @param null|User        $newOwner
  * @param Integration|null $oldIntegration
  * @param bool             $expectOwnerSetEvent
  * @param bool             $expectIntegrationUpdateEvent
  */
 public function testEventDispatching($entity, $newOwner, $oldIntegration, $expectOwnerSetEvent, $expectIntegrationUpdateEvent)
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($entity)->will($this->returnCallback(function ($entity) use($newOwner) {
         $entity->setDefaultUserOwner($newOwner);
     }));
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->em->expects($this->once())->method('persist')->with($entity);
     $this->em->expects($this->once())->method('flush');
     if ($entity->getId()) {
         $this->em->expects($this->once())->method('find')->with('OroIntegrationBundle:Channel', $entity->getId())->will($this->returnValue($oldIntegration));
     }
     $dispatchCallIndex = 0;
     if ($expectOwnerSetEvent) {
         $this->eventDispatcher->expects($this->at($dispatchCallIndex++))->method('dispatch')->with($this->equalTo(DefaultOwnerSetEvent::NAME), $this->isInstanceOf('Oro\\Bundle\\IntegrationBundle\\Event\\DefaultOwnerSetEvent'));
     }
     if ($expectIntegrationUpdateEvent) {
         $this->eventDispatcher->expects($this->at($dispatchCallIndex++))->method('dispatch')->with($this->equalTo(IntegrationUpdateEvent::NAME), $this->callback(function ($event) use($entity, $oldIntegration) {
             $this->assertInstanceOf('Oro\\Bundle\\IntegrationBundle\\Event\\IntegrationUpdateEvent', $event);
             $this->assertSame($entity, $event->getIntegration());
             $this->assertEquals($oldIntegration, $event->getOldState());
             return true;
         }));
     } elseif (!$expectOwnerSetEvent) {
         $this->eventDispatcher->expects($this->never())->method('dispatch');
     }
     $this->assertTrue($this->handler->process($entity));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:38,代码来源:IntegrationHandlerTest.php

示例15: testScheduleSourceProcessOnSourceUnlinked

 /**
  * Tests that a source is scheduled for processing if it's unlinked.
  */
 public function testScheduleSourceProcessOnSourceUnlinked()
 {
     $this->listener->expects($this->once())->method('isSourceModified')->will($this->returnValue(false));
     $this->sourceProcessor->expects($this->once())->method('isLinked')->will($this->returnValue(false));
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(IoEvents::SOURCE_PROCESS));
     $this->listener->onFlush($this->getOnFlushEventArgs(new SourceMock(12345)));
     $this->listener->postFlush(new PostFlushEventArgs($this->entityManager));
 }
开发者ID:treehouselabs,项目名称:io-bundle,代码行数:11,代码来源:SourceModificationListenerTest.php


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