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); }
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); }
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()); }
/** * @param Process $process */ public function publish(Process $process) { $this->processProducer->publish($this->processSerializer->serialize($process)); }
/** * {@inheritdoc} */ public function execute(AMQPMessage $message) { $this->processRunner->run($this->processSerializer->deserialize($message->body)); }