public function testPublish()
 {
     $process = $this->createProcessMock();
     $this->processSerializer->expects($this->once())->method('serialize')->with($this->identicalTo($process))->will($this->returnValue($serialized = 'serialized'));
     $this->processProducer->expects($this->once())->method('publish')->with($this->identicalTo($serialized));
     $this->producer->publish($process);
 }
Exemple #2
0
 /**
  * @param mixed[] $headers
  * @param string  $body
  */
 public function handle(array $headers, $body)
 {
     if (!$this->firewall->authorize($headers, $body)) {
         throw new BadRequestHttpException('The request signature is not valid.');
     }
     if (!is_array($payload = json_decode($body, true))) {
         throw new BadRequestHttpException('The request json body cannot be decoded.');
     }
     $this->eventDispatcher->dispatch(WebhookEvents::HOOK, $event = new WebhookEvent($payload));
     foreach ($event->getProcesses() as $process) {
         $this->processProducer->publish($process);
     }
 }