Skip to content

Commit

Permalink
Merge branch 'master' into v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
peppeocchi committed Oct 14, 2017
2 parents 37e3877 + fe644ed commit 9cd1ea0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/GO/Scheduler.php
Expand Up @@ -119,6 +119,10 @@ public function call(callable $fn, $args = [], $id = null)
*/
public function php($script, $bin = null, $args = [], $id = null)
{
if (! is_string($script) || ! file_exists($script)) {
throw new InvalidArgumentException('The script should be a valid path to a file.');
}

$bin = $bin !== null && is_string($bin) && file_exists($bin) ?
$bin : (PHP_BINARY === '' ? '/usr/bin/php' : PHP_BINARY);

Expand Down
24 changes: 24 additions & 0 deletions tests/GO/SchedulerTest.php
Expand Up @@ -30,6 +30,30 @@ public function testShouldQueueAPhpScript()
$this->assertEquals(count($scheduler->getQueuedJobs()), 1);
}

/**
* @expectedException InvalidArgumentException
*/
public function testShouldThrowExceptionIfScriptIsNotAString()
{
$scheduler = new Scheduler();
$scheduler->php(function () {
return false;
});

$scheduler->run();
}

/**
* @expectedException InvalidArgumentException
*/
public function testShouldThrowExceptionIfScriptPathIsInvalid()
{
$scheduler = new Scheduler();
$scheduler->php('someInvalidPathToAScript');

$scheduler->run();
}

public function testShouldQueueAShellCommand()
{
$scheduler = new Scheduler();
Expand Down

0 comments on commit 9cd1ea0

Please sign in to comment.