-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Indatus/develop
Improvements/fixes to scheduling
- Loading branch information
Showing
10 changed files
with
149 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* @author Ben Kuhl <[email protected]> | ||
*/ | ||
namespace Indatus\Dispatcher; | ||
|
||
interface ScheduledCommandInterface | ||
{ | ||
/** | ||
* User to run the command as | ||
* @return string Defaults to false to run as default user | ||
*/ | ||
public function user(); | ||
|
||
/** | ||
* When a command should run | ||
* @param Schedulable $scheduler | ||
* @return \Indatus\Dispatcher\Schedulable | ||
*/ | ||
public function schedule(Schedulable $scheduler); | ||
|
||
/** | ||
* Environment(s) under which the given command should run | ||
* Defaults to '*' for all environments | ||
* @return string | ||
*/ | ||
public function environment(); | ||
|
||
/** | ||
* Checks whether the command is enabled or not in the current environment | ||
* Override this to check for x or y and return false if the command can not | ||
* run properly under the current conditions. | ||
* @return Boolean | ||
*/ | ||
public function isEnabled(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* @author Ben Kuhl <[email protected]> | ||
*/ | ||
|
||
use Mockery as m; | ||
|
||
class TestCronScheduleService extends TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
parent::tearDown(); | ||
m::close(); | ||
} | ||
|
||
/** | ||
* Test that a summary is properly generated | ||
* Dangit this is ugly... gotta find a new cli library | ||
*/ | ||
public function testPrintSummary() | ||
{ | ||
$table = m::mock('Indatus\Dispatcher\Table', function ($m) { | ||
$m->shouldReceive('setHeaders')->once(); | ||
$m->shouldReceive('sort')->once(); | ||
$m->shouldReceive('display')->once(); | ||
}); | ||
$scheduledCommand = m::mock('Indatus\Dispatcher\ScheduledCommand', function ($m) use ($table) { | ||
$table->shouldReceive('addRow')->once(); | ||
|
||
$m->shouldReceive('getName')->once(); | ||
$m->shouldReceive('user')->once(); | ||
$m->shouldReceive('environment')->twice(); | ||
$m->shouldReceive('schedule')->once()->andReturn(m::mock('Indatus\Dispatcher\Drivers\Cron\Scheduler', function ($m) { | ||
$m->shouldReceive('getScheduleMinute'); | ||
$m->shouldReceive('getScheduleHour'); | ||
$m->shouldReceive('getScheduleDayOfMonth'); | ||
$m->shouldReceive('getScheduleMonth'); | ||
$m->shouldReceive('getScheduleDayOfWeek'); | ||
})); | ||
}); | ||
$scheduleService = m::mock('Indatus\Dispatcher\Drivers\Cron\ScheduleService[getScheduledCommands]', array( | ||
$table | ||
), function ($m) use ($scheduledCommand) { | ||
$m->shouldReceive('getScheduledCommands')->once()->andReturn(array( | ||
$scheduledCommand | ||
)); | ||
}); | ||
$scheduleService->printSummary(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters