Esempio n. 1
0
 public function testShouldNotExecuteIfTruthTestFalse()
 {
     $job = JobFactory::factory('GO\\Job\\Raw', 'somecommand')->at('* * * * *')->when(function () {
         return false;
     });
     $this->assertFalse($job->isDue());
 }
Esempio n. 2
0
 public function testShouldCompileCommandWithCustomBin()
 {
     $bin = '/usr/bin/php';
     $job = JobFactory::factory('GO\\Job\\Php', 'somecommand');
     $job->useBin($bin);
     $compiled = $job->build();
     $this->assertEquals($bin . ' somecommand > /dev/null 2>&1 &', $compiled);
 }
 public function testShouldRunInForeground()
 {
     $closure = function ($nums) {
         return array_sum($nums);
     };
     $args = [2, 3];
     $job = JobFactory::factory('GO\\Job\\Closure', $closure, $args);
     $job->build();
     $this->assertFalse($job->runInBackground);
 }
 public function testShouldLogJobDoneMessage()
 {
     $job = JobFactory::factory('GO\\Job\\Closure', function () {
         return "closureoutput";
     });
     $loggerMock = $this->getPsrLoggerMock();
     $loggerMock->expects($this->at(0))->method('info')->with('', ['closureoutput']);
     $loggerMock->expects($this->at(1))->method('info')->with('', ['job done']);
     $job->setJobDoneMessage('job done')->setLogger($loggerMock);
     $job->exec();
 }
Esempio n. 5
0
 public function testShouldSetTrueIfNoCallbackProvidedWithDoNotOverlap()
 {
     $job = JobFactory::factory('GO\\Job\\Php', 'some command')->at('* * * * *')->doNotOverlap();
     $this->assertTrue($job->preventOverlap());
 }
Esempio n. 6
0
 public function testShouldReturnRawJobInstance()
 {
     $this->assertInstanceOf('Go\\Job\\Raw', JobFactory::factory('GO\\Job\\Raw', 'some command'));
 }
 public function testFactoryReturnsJobInstance()
 {
     $this->assertInstanceOf('Go\\Job\\Job', JobFactory::factory('GO\\Job\\Php', 'some command'));
 }
 /**
  * Closure job
  *
  * @param callable $closure
  * @return \GO\Job\Job
  */
 public function call($closure)
 {
     return $this->jobs[] = JobFactory::factory(\GO\Job\Closure::class, $closure);
 }