コード例 #1
0
 /**
  * @param RequestObject $requestObject
  * @param array         $collectorParameters
  */
 public function dispatch(RequestObject $requestObject, array $collectorParameters)
 {
     if (true === $collectorParameters['logger']['enabled']) {
         $this->loggerCollector->collect($requestObject, ['logFile' => $collectorParameters['logger']['file']]);
     }
     if (true === $collectorParameters['persister']['enabled']) {
         $this->persisterCollector->collect($requestObject);
     }
     if (true === $collectorParameters['mailer']['enabled']) {
         $this->mailerCollector->collect($requestObject, ['email' => $collectorParameters['mailer']['email']]);
     }
 }
コード例 #2
0
 /**
  * @test
  * @dataProvider dispatcherDataProvider
  *
  * @param array $configuration
  */
 public function itShouldDipatch($configuration)
 {
     $dispatcher = new DispatcherCollector();
     $requestObject = new RequestObject();
     $dispatcher->setLoggerCollector($this->logger->reveal());
     $dispatcher->setPersisterCollector($this->persister->reveal());
     $dispatcher->setMailerCollector($this->mailer->reveal());
     if ($configuration['logger']['enabled']) {
         $this->logger->collect(Argument::type(RequestObject::class), Argument::type('array'))->shouldBeCalled();
     } else {
         $this->logger->collect(Argument::type(RequestObject::class), Argument::type('array'))->shouldNotBeCalled();
     }
     if ($configuration['persister']['enabled']) {
         $this->persister->collect(Argument::type(RequestObject::class))->shouldBeCalled();
     } else {
         $this->persister->collect(Argument::type(RequestObject::class))->shouldNotBeCalled();
     }
     if ($configuration['mailer']['enabled']) {
         $this->mailer->collect(Argument::type(RequestObject::class), Argument::type('array'))->shouldBeCalled();
     } else {
         $this->mailer->collect(Argument::type(RequestObject::class), Argument::type('array'))->shouldNotBeCalled();
     }
     $dispatcher->dispatch($requestObject, $configuration);
 }