public function testShouldNotExecuteIfTruthTestFalse()
 {
     $job = JobFactory::factory('GO\\Job\\Raw', 'somecommand')->at('* * * * *')->when(function () {
         return false;
     });
     $this->assertFalse($job->isDue());
 }
 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();
 }
 public function testShouldSetTrueIfNoCallbackProvidedWithDoNotOverlap()
 {
     $job = JobFactory::factory('GO\\Job\\Php', 'some command')->at('* * * * *')->doNotOverlap();
     $this->assertTrue($job->preventOverlap());
 }
 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);
 }