Пример #1
0
 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);
 }
Пример #2
0
 public function testExecute()
 {
     $message = $this->createAmqpMessageMock();
     $message->body = $body = '{"foo":"bar"}';
     $this->serializer->expects($this->once())->method('deserialize')->with($this->identicalTo($body))->will($this->returnValue($process = $this->createProcessMock()));
     $this->runner->expects($this->once())->method('run')->with($this->identicalTo($process));
     $this->consumer->execute($message);
 }
Пример #3
0
 public function testDeserialize()
 {
     $serialized = json_encode(['command' => $command = 'foo.sh', 'timeout' => $timeout = 60]);
     $process = $this->serializer->deserialize($serialized);
     $this->assertInstanceOf(Process::class, $process);
     $this->assertSame($command, $process->getCommandLine());
     $this->assertSame((double) $timeout, $process->getTimeout());
 }
Пример #4
0
 /**
  * @param Process $process
  */
 public function publish(Process $process)
 {
     $this->processProducer->publish($this->processSerializer->serialize($process));
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function execute(AMQPMessage $message)
 {
     $this->processRunner->run($this->processSerializer->deserialize($message->body));
 }