public function testRun()
 {
     $a = new Job('a');
     $b = new Job('b', array('foo'));
     $b->addDependency($a);
     $this->em->persist($a);
     $this->em->persist($b);
     $this->em->flush();
     $output = $this->doRun(array('--max-runtime' => 5));
     $expectedOutput = "Started Job(id = 1, command = \"a\").\n" . "Job(id = 1, command = \"a\") finished with exit code 1.\n";
     $this->assertEquals($expectedOutput, $output);
     $this->assertEquals('failed', $a->getState());
     $this->assertEquals('', $a->getOutput());
     $this->assertContains('Command "a" is not defined.', $a->getErrorOutput());
     $this->assertEquals('canceled', $b->getState());
 }
예제 #2
0
 public function testHasDependency()
 {
     $a = new Job('a');
     $b = new Job('b');
     $this->assertFalse($a->hasDependency($b));
     $a->addDependency($b);
     $this->assertTrue($a->hasDependency($b));
 }
 public function testCloseJobDoesNotCreateRetryJobsWhenCanceled()
 {
     $a = new Job('a');
     $a->setMaxRetries(4);
     $b = new Job('b');
     $b->setMaxRetries(4);
     $b->addDependency($a);
     $this->em->persist($a);
     $this->em->persist($b);
     $this->em->flush();
     $this->dispatcher->expects($this->at(0))->method('dispatch')->with('jms_job_queue.job_state_change', new StateChangeEvent($a, 'canceled'));
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with('jms_job_queue.job_state_change', new StateChangeEvent($b, 'canceled'));
     $this->repo->closeJob($a, 'canceled');
     $this->assertEquals('canceled', $a->getState());
     $this->assertCount(0, $a->getRetryJobs());
     $this->assertEquals('canceled', $b->getState());
     $this->assertCount(0, $b->getRetryJobs());
 }