Exemplo n.º 1
0
 public function testEntityProperties()
 {
     $transition = new Transition();
     $transition_id = 2;
     $worker_id = 'efgh-ijhg-kjhf-kjjd';
     $job_id = 'abcd-efgh-ijkl-mnop';
     $state_id = 1;
     $occured = new DateTime();
     $message = 'a transition msg';
     $process_handle = 'abcd-efgh-ijkl-mnop';
     $transition->setTransitionId($transition_id);
     $transition->setJob($job_id);
     $transition->setWorker($worker_id);
     $transition->setOccured($occured);
     $transition->setMessage($message);
     $transition->setState($state_id);
     $transition->setProcessHandle($process_handle);
     $this->assertEquals($transition_id, $transition->getTransitionId());
     $this->assertEquals($message, $transition->getMessage());
     $this->assertEquals($state_id, $transition->getState());
     $this->assertEquals($worker_id, $transition->getWorker());
     $this->assertEquals($job_id, $transition->getJob());
     $this->assertEquals($occured, $transition->getOccured());
     $this->assertEquals($process_handle, $transition->getProcessHandle());
 }
 public function testErrorTransitionHandler()
 {
     $gateway = $this->getTableGateway();
     $handler = new WorkerSubscriber($gateway);
     $mock_worker = $this->getMockBuilder('LaterJob\\Worker')->disableOriginalConstructor()->getMock();
     $uuid = new UUID(new MersenneRandom());
     $worker_name = 'test_worker_1';
     # create the transition
     $transition = new Transition();
     $transition->setWorker($uuid->v3($uuid->v4(), $worker_name));
     $transition->setState(WorkerConfig::STATE_ERROR);
     $transition->setOccured(new DateTime());
     $transition->setMessage('worker error');
     # create the event object
     $transition_event = new WorkerTransitionEvent($mock_worker, $transition);
     # run through handler
     $handler->onWorkerError($transition_event);
     # no exceptions raised by failed recording
     $this->assertGreaterThan(0, $transition->getTransitionId());
 }
 public function testTransitionErrorHandler()
 {
     $gateway = $this->getTableGateway();
     $handler = new JobSubscriber($gateway);
     $mock_job = $this->getMockBuilder('LaterJob\\Job')->disableOriginalConstructor()->getMock();
     $uuid = new UUID(new MersenneRandom());
     $worker_name = 'test_job_1';
     $process_handler = '01b89534-cf6e-3a63-b7fe-8e6b5a729483';
     # create the transition
     $transition = new Transition();
     $transition->setJob($uuid->v3($uuid->v4(), $worker_name));
     $transition->setState(QueueConfig::STATE_ERROR);
     $transition->setOccured(new DateTime());
     $transition->setMessage('job encountered error');
     $transition->setProcessHandle($process_handler);
     # create the event object
     $transition_event = new JobTransitionEvent($mock_job, $transition);
     # run through handler
     $handler->onJobError($transition_event);
     $this->assertGreaterThan(0, $transition->getTransitionId());
 }
 public function toArray(Transition $entity)
 {
     return array('transitionId' => $entity->getTransitionId(), 'dateOccured' => $entity->getOccured(), 'stateId' => $entity->getState(), 'workerId' => $entity->getWorker(), 'jobId' => $entity->getJob(), 'transitionMessage' => $entity->getMessage(), 'processHandle' => $entity->getProcessHandle());
 }