public function getData() { $ack = new JobAcknowledgement(); $nack = new JobNotAcknowledgement(); $nack->setReason('Man machine'); return array(array($ack, $ack->toJson()), array($nack, $nack->toJson())); }
/** @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']); }
/** @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)); }