/**
  * @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));
 }
 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);
 }
 /**
  * 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();
 }
 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);
 }
 /**
  * @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;
 }
Example #6
0
 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());
 }
 /**
  * @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));
 }
 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);
 }
 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]);
 }
Example #10
0
 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));
 }
Example #11
0
 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);
 }
Example #12
0
 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);
 }
 /**
  * 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());
 }
 /**
  * @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));
 }
 /**
  * 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));
 }
Example #16
0
 public function testOnScrollDataBefore()
 {
     /** @var \Twig_Environment $environment */
     $environment = $this->getMock('\\Twig_Environment');
     $pageIdentifier = 'test-page';
     $data = new ScrollData(['fields']);
     $alteredData = new ScrollData(['altered', 'fields']);
     /** @var FormView $formView */
     $formView = $this->getMock('Symfony\\Component\\Form\\FormView');
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with('oro_ui.scroll_data.before.' . $pageIdentifier, $this->isInstanceOf('Oro\\Bundle\\UIBundle\\Event\\BeforeListRenderEvent'))->willReturnCallback(function ($name, BeforeListRenderEvent $event) use($environment, $data, $alteredData, $formView) {
         $this->assertEquals($environment, $event->getEnvironment());
         $this->assertEquals($data, $event->getScrollData());
         $this->assertEquals($formView, $event->getFormView());
         $event->setScrollData($alteredData);
     });
     $this->assertEquals($alteredData->getData(), $this->extension->scrollDataBefore($environment, $pageIdentifier, $data->getData(), $formView));
 }
 /**
  * Test has listeners
  */
 public function testHasListeners()
 {
     $this->eventDispatcher->expects($this->any())->method('hasListeners')->with($this->anything())->will($this->returnCallback(function ($eventName) {
         return $eventName == 'foo' ? true : false;
     }));
     $this->assertFalse($this->notifierProxy->hasListeners('bar'));
     $this->assertTrue($this->notifierProxy->hasListeners('foo'));
 }
 public function testDefaultSiteAccess()
 {
     $this->dispatcher->expects($this->once())->method('dispatch');
     $input = new ArrayInput(array(), $this->inputDefinition);
     $event = new ConsoleCommandEvent($this->command, $input, $this->testOutput);
     $this->listener->onConsoleCommand($event);
     $this->assertEquals(new SiteAccess('default', 'cli'), $this->siteAccess);
 }
Example #19
0
 /**
  * @param Channel $entity
  * @param mixed $requestValue
  * @param string $expectedType
  *
  * @dataProvider handleRequestDataProvider
  */
 public function testHandleRequestChannelType(Channel $entity, $requestValue, $expectedType)
 {
     $this->request->setMethod('GET');
     $expectedEntity = clone $entity;
     $expectedEntity->setChannelType($expectedType);
     $this->form->expects($this->once())->method('setData')->with($expectedEntity);
     $this->form->expects($this->never())->method('submit');
     $this->dispatcher->expects($this->never())->method('dispatch');
     $this->request->request->set('orocrm_channel_form', ['channelType' => $requestValue]);
     $this->handler->process($entity);
 }
 /**
  * @test
  */
 public function loadMetadataCreateNewClassMetadata()
 {
     $expectedResult = new ClassMetadata\ClassMetadata('Kassko\\DataMapperTest\\ClassMetadata\\Fixture\\SampleClass');
     $cacheKey = 'testCacheKey';
     $this->objectKeyMock->expects($this->once())->method('getKey')->willReturn($cacheKey);
     $this->objectKeyMock->expects($this->once())->method('getClass')->willReturn('Kassko\\DataMapperTest\\ClassMetadata\\Fixture\\SampleClass');
     $this->loaderMock->expects($this->once())->method('loadClassMetadata')->with($expectedResult, $this->loadingCriteriaMock, $this->configurationMock);
     $this->cacheMock->expects($this->once())->method('save')->with($cacheKey);
     $this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ClassMetadata\Events::POST_LOAD_METADATA);
     $result = $this->classMetadataFactory->loadMetadata($this->objectKeyMock, $this->loadingCriteriaMock, $this->configurationMock);
     $this->assertEquals($expectedResult, $result);
 }
 public function testConfirmFalse()
 {
     $this->request->expects($this->once())->method('get')->with('token')->willReturn('awesome-token');
     $this->filesystem->expects($this->once())->method('exists')->with(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'awesome-token' . '.txt')->willReturn(true);
     $this->mollieAPIClient->payments = $this->payments;
     file_put_contents(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'awesome-token' . '.txt', 'test');
     $this->payments->expects($this->once())->method('get')->with('test')->willReturn($this->paymentObject);
     $this->paymentObject->expects($this->once())->method('isPaid')->willReturn(false);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(PaymentEvents::PAYMENT_FAILED);
     $this->filesystem->expects($this->never())->method('remove');
     $this->assertFalse($this->mollieDriver->confirm($this->request));
 }
 public function testClearRootAssetMappingsDispatchesEvent()
 {
     $mapping1 = new AssetMapping('/path', 'target1', '/css', $this->binding1->getUuid());
     $mapping2 = new AssetMapping('/other/path', 'target2', '/js', $this->binding2->getUuid());
     $event1 = new RemoveAssetMappingEvent($mapping1);
     $event2 = new RemoveAssetMappingEvent($mapping2);
     $this->dispatcher->expects($this->at(0))->method('hasListeners')->with(PuliEvents::POST_REMOVE_ASSET_MAPPING)->willReturn(true);
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with(PuliEvents::POST_REMOVE_ASSET_MAPPING, $event1);
     $this->dispatcher->expects($this->at(2))->method('dispatch')->with(PuliEvents::POST_REMOVE_ASSET_MAPPING, $event2);
     $this->discoveryManager->expects($this->once())->method('findRootBindings')->with($this->defaultExpr())->willReturn(array($this->binding1, $this->binding2));
     $this->discoveryManager->expects($this->once())->method('removeRootBindings')->with($this->defaultExpr());
     $this->manager->clearRootAssetMappings();
 }
Example #23
0
 public function testFlushByPassException()
 {
     $this->resource->expects($this->exactly(2))->method('getName')->will($this->returnValue($name = 'name'));
     $this->objectManager->expects($this->once())->method('flush')->will($this->throwException(new \Exception()));
     $this->eventDispatcher->expects($this->at(0))->method('dispatch')->with($this->identicalTo('lug.' . $name . '.pre_' . ($action = 'flush')), $this->callback(function (DomainEvent $event) use($action) {
         return $event->getResource() === $this->resource && $event->getObject() === null && $event->getAction() === $action;
     }));
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with($this->identicalTo('lug.' . $name . '.error_' . $action), $this->callback(function (DomainEvent $event) use($action) {
         $result = $event->getResource() === $this->resource && $event->getObject() === null && $event->getAction() === $action;
         $event->setStopped(false);
         return $result;
     }));
     $this->domainManager->flush();
 }
Example #24
0
 public function testLinkExistingAccount()
 {
     $account = $this->getMock('Drupal\\user\\UserInterface');
     $account->expects($this->once())->method('id')->will($this->returnValue(5));
     // Set up a mock for Authmap class,
     // mocking get() & save() methods
     $authmap = $this->getMockBuilder('\\Drupal\\externalauth\\Authmap')->disableOriginalConstructor()->setMethods(array('save', 'get'))->getMock();
     $authmap->expects($this->once())->method('get')->will($this->returnValue(FALSE));
     $authmap->expects($this->once())->method('save');
     $dispatched_event = $this->getMockBuilder('\\Drupal\\externalauth\\Event\\ExternalAuthAuthmapAlterEvent')->disableOriginalConstructor()->getMock();
     $dispatched_event->expects($this->any())->method('getUsername')->will($this->returnValue("Test username"));
     $dispatched_event->expects($this->any())->method('getAuthname')->will($this->returnValue("Test authname"));
     $dispatched_event->expects($this->any())->method('getData')->will($this->returnValue("Test data"));
     $this->eventDispatcher->expects($this->any())->method('dispatch')->will($this->returnValue($dispatched_event));
     $externalauth = new ExternalAuth($this->entityManager, $authmap, $this->logger, $this->eventDispatcher);
     $externalauth->linkExistingAccount("test_authname", "test_provider", $account);
 }
 public function testGetCached()
 {
     $options = array();
     $alias = 'test_menu';
     $items = array('name' => $alias);
     $menu = $this->getMockBuilder('Knp\\Menu\\ItemInterface')->getMock();
     $cache = $this->getMockBuilder('Doctrine\\Common\\Cache\\ArrayCache')->getMock();
     $cache->expects($this->once())->method('contains')->with($alias)->will($this->returnValue(true));
     $cache->expects($this->once())->method('fetch')->with($alias)->will($this->returnValue($items));
     $this->factory->expects($this->once())->method('createFromArray')->with($items)->will($this->returnValue($menu));
     $this->factory->expects($this->never())->method('createItem');
     $builder = $this->getMenuBuilderMock();
     $builder->expects($this->never())->method('build');
     $this->eventDispatcher->expects($this->never())->method('dispatch');
     $this->provider->addBuilder($builder, $alias);
     $this->provider->setCache($cache);
     $this->assertAttributeCount(1, 'menus', $this->provider);
 }
 /**
  * @param string $processMethod
  * @param string $eventSuffix
  * @return TestMultiEntityModel
  */
 protected function setEntityTestExpectations($processMethod, $eventSuffix)
 {
     $firstEntity = new \DateTime('2015-03-03');
     $secondEntity = new \DateTime('2015-04-04');
     $sourceModel = new TestMultiEntityModel(new \DateTime('2015-01-01'), new \DateTime('2015-02-02'));
     $alteredModel = new TestMultiEntityModel($firstEntity, $secondEntity);
     // alter model in event
     $this->eventDispatcher->expects($this->at(0))->method('dispatch')->with('model.' . $eventSuffix . '.before.test_multi_entity_model')->willReturnCallback(function ($name, ModelEvent $event) use($sourceModel, $alteredModel) {
         self::assertEquals($sourceModel, $event->getModel());
         $event->setModel($alteredModel);
     });
     $objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $objectManager->expects($this->at(0))->method($processMethod)->with($firstEntity);
     $objectManager->expects($this->at(1))->method($processMethod)->with($secondEntity);
     $objectManager->expects($this->at(2))->method('flush');
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with(self::ENTITY_CLASS)->willReturn($objectManager);
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with('model.' . $eventSuffix . '.after.test_multi_entity_model', new ModelEvent($alteredModel));
     $this->repository = new ModelRepository($this->managerRegistry, $this->eventDispatcher, $this->modelFactory, self::MULTI_ENTITY_MODEL_CLASS, self::ENTITY_CLASS);
     return $sourceModel;
 }
 public function testProcessHandlesExceptions()
 {
     $schedules = $this->createSchedules(2);
     $this->initManager($schedules);
     $exception = new \Exception();
     $this->processor->expects($this->any())->method('process')->will($this->returnValue(true));
     $this->processor->expects($this->at(0))->method('process')->will($this->throwException($exception));
     $this->dispatcher->expects($this->once())->method('dispatch');
     $this->manager->expects($this->once())->method('save');
     try {
         $this->subject->process(new ScheduleManagerScheduleIterator($this->manager));
         $this->fail('throws SchedulerException');
     } catch (SchedulerException $e) {
         $this->assertEquals(1, $e->getNumOfProcessed());
         $schedulerExceptions = $e->getScheduleExceptions();
         $this->assertCount(1, $schedulerExceptions);
         /** @var ScheduleException $schedulerException */
         $schedulerException = $schedulerExceptions[0];
         $this->assertSame($exception, $schedulerException->getException());
         // elements are popped, that's why the last element of $schedules must be the same
         $this->assertSame($schedules[1], $schedulerException->getSchedule());
     }
 }
 /**
  * @covers ::preRefundPayment
  *
  */
 public function testPreRefundPayment()
 {
     $paymentMethod = $this->getMock(PaymentMethodInterface::class);
     $this->symfonyEventDispatcher->expects($this->once())->method('dispatch')->with(PaymentEvents::PRE_REFUND_PAYMENT, $this->isInstanceOf(PreRefundPayment::class));
     $this->sut->preRefundPayment($paymentMethod);
 }
 /**
  * @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
  */
 public function testMatchNoRequest()
 {
     $this->router->setRequest(null);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::PRE_DYNAMIC_MATCH, $this->equalTo(new RouterMatchEvent()));
     $this->router->match('/foo');
 }
 /**
  * Testing notifyPaymentFail.
  */
 public function testNotifyPaymentOrderFail()
 {
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(PaymentCoreEvents::PAYMENT_ORDER_FAIL), $this->isInstanceOf('PaymentSuite\\PaymentCoreBundle\\Event\\PaymentOrderFailEvent'));
     $paymentEventDispatcher = new PaymentEventDispatcher($this->eventDispatcher);
     $paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $this->paymentMethod);
 }