Ejemplo n.º 1
0
 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);
     return array(array($image, $image->toJson()), array($video, $video->toJson()));
 }
Ejemplo n.º 2
0
 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()));
 }
Ejemplo n.º 3
0
 public function getDeliveries()
 {
     $amazon = AmazonS3::create('bucket', 'object', array(), 'public', 24);
     $filesystem = Filesystem::create('/path/to/target');
     return array(array($amazon, $amazon->toArray()), array($filesystem, $filesystem->toArray()));
 }
Ejemplo n.º 4
0
 public function getJob()
 {
     $job = new VideoJob();
     return $job->setSource(__DIR__ . '/../../../../testfiles/photo02.JPG')->setDelivery(Filesystem::create(__DIR__ . '/../../../../target.jpg'));
 }
Ejemplo n.º 5
0
 public function testFilesystemFromArray()
 {
     $delivery = $this->getDelivery();
     $this->assertEquals($delivery, Filesystem::fromArray($delivery->toArray()));
 }
Ejemplo n.º 6
0
 public function testWithOptions()
 {
     $parameters = array('width' => 320, 'height' => 240, 'format' => 'gif', 'resize-mode' => ImageJob::RESIZE_INBOUND, 'resolution-units' => ImageJob::RESOLUTION_PER_CENTIMETERS, 'resolution' => 200, 'strip' => true, 'rotation' => 90, 'quality' => 100);
     $job = ImageJob::create(__DIR__ . '/../../../testfiles/photo02.JPG', Filesystem::create($this->target), $parameters);
     $message = $this->getAMQPMessage($job->toJson());
     $this->getWorker()->process($message);
     $this->assertTrue(file_exists($this->target));
 }
Ejemplo n.º 7
0
 public function getJob()
 {
     $job = new ImageJob();
     return $job->setSource(__DIR__ . '/../../../../testfiles/photo02.JPG')->setDelivery(Filesystem::create(__DIR__ . '/../../../../target.jpg'))->setParameters(array('format' => 'png'));
 }
Ejemplo n.º 8
0
 public function testProcessWithWrongJobType()
 {
     $job = $this->getWrongJob(Filesystem::create($this->target));
     $this->assertTrue($job->isOk());
     $json = $job->toJson();
     $data = json_decode($json, true);
     $data['type'] = 'Gloubster\\Message\\Job\\ImageJob';
     $json = json_encode($data);
     $message = $this->getAMQPMessage($json);
     $channel = $this->getChannel();
     $this->ensureAcknowledgement($channel, $message->delivery_info['delivery_tag']);
     $this->probePublishValues($channel, false, Configuration::ROUTINGKEY_LOG);
     try {
         $this->getWorker($channel)->process($message);
         $this->fail('Should have raised an exception');
     } catch (RuntimeException $e) {
     }
 }