public function getData() { $delivery = new FilesystemDelivery(); $delivery->setTarget('/path/to/Target'); /** * @todo add receipts */ $receipts = array(); $image = new ImageJob(); $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts); $video = new VideoJob(); $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts); $presence = new WorkerPresence(); $presence->setWorkerType('worker-type')->setFailureJobs(mt_rand())->setId(mt_rand())->setMemory(123456789)->setStartedTime(223456789.98765433)->setLastJobTime(333456789.9876543)->setTotalJobs(mt_rand())->setSuccessJobs(mt_rand())->setReportTime(444456789.98765445)->setIdle(true); return array(array($image, $image->toJson()), array($video, $video->toJson()), array($presence, $presence->toJson())); }
/** * @covers Gloubster\Message\Presence\WorkerPresence::getArrayData * @covers Gloubster\Message\AbstractMessage::toJson * @covers Gloubster\Message\AbstractMessage::fromJson */ public function testFromToJson() { $type = 'worker-type'; $this->object->setWorkerType($type); $total = mt_rand(); $this->object->setFailureJobs($total); $id = mt_rand(); $this->object->setId($id); $memory = 123456789; $this->object->setMemory($memory); $time = 223456789.98765433; $this->object->setStartedTime($time); $time = 333456789.9876543; $this->object->setLastJobTime($time); $total = mt_rand(); $this->object->setTotalJobs($total); $success = mt_rand(); $this->object->setSuccessJobs($success); $time = 444456789.98765445; $this->object->setReportTime($time); $idle = true; $this->object->setIdle($idle); $this->assertEquals($this->object, WorkerPresence::fromJson($this->object->toJson())); }
/** * @expectedException Gloubster\Exception\RuntimeException * @covers Gloubster\Message\Acknowledgement\Factory::fromJson */ public function testFromJsonFailsWithWrongType() { $presence = new WorkerPresence(); $presence->setWorkerType('worker-type')->setFailureJobs(mt_rand())->setId(mt_rand())->setMemory(123456789)->setStartedTime(223456789.98765433)->setLastJobTime(333456789.9876543)->setTotalJobs(mt_rand())->setSuccessJobs(mt_rand())->setReportTime(444456789.98765445)->setIdle(true); Factory::fromJson($presence->toJson()); }