コード例 #1
0
 public function getData()
 {
     $ack = new JobAcknowledgement();
     $nack = new JobNotAcknowledgement();
     $nack->setReason('Man machine');
     return array(array($ack, $ack->toJson()), array($nack, $nack->toJson()));
 }
コード例 #2
0
 /** @test */
 public function itMustBeSerializable()
 {
     $ack = new JobAcknowledgement();
     $date = new \DateTime('+5days');
     $ack->setCreatedOn($date);
     $data = json_decode($ack->toJson(), true);
     $this->assertEquals($date->format(DATE_ATOM), $data['createdOn']);
 }
コード例 #3
0
ファイル: ZMQClientTest.php プロジェクト: gloubster/client
 /** @test */
 public function itShouldSendMessageAndReceiveAcknowledgement()
 {
     $transport = 'ipc';
     $host = 'local.gloubster';
     $port = '1234';
     $context = $this->getContext();
     $socket = $this->getSocket();
     $context->expects($this->once())->method('getSocket')->with($this->equalTo(\ZMQ::SOCKET_REQ), $this->anything())->will($this->returnValue($socket));
     $job = $this->getMockBuilder('Gloubster\\Message\\Job\\ImageJob')->disableOriginalConstructor()->getMock();
     $ack = new JobAcknowledgement();
     $json = '{"hello": "world !"}';
     $socket->expects($this->once())->method('send')->with($json);
     $socket->expects($this->once())->method('recv')->will($this->returnValue($ack->toJson()));
     $job->expects($this->any())->method('toJson')->will($this->returnValue($json));
     $client = new ZMQClient($context, $transport, $host, $port);
     $this->assertEquals($ack, $client->send($job));
 }