-
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 #61 from troyharvey/47-fortnights
Support for scheduling fortnight commands #47
- Loading branch information
Showing
2 changed files
with
70 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* @author Ben Kuhl <[email protected]> | ||
*/ | ||
|
||
use Mockery as m; | ||
use Indatus\Dispatcher\Drivers\Cron\Scheduler; | ||
|
||
class TestCronScheduler extends TestCase | ||
|
@@ -50,6 +51,28 @@ public function testMonthly() | |
$this->assertEquals($this->scheduler->getSchedule(), '0 0 1 '.Scheduler::ANY.' '.Scheduler::ANY); | ||
} | ||
|
||
public function testEveryOtherWeekEven() | ||
{ | ||
$carbon = m::mock(); | ||
$carbon->shouldReceive('now')->andReturn($carbon); | ||
$carbon->weekOfYear = 32; | ||
App::instance('Carbon', $carbon); | ||
|
||
$this->assertInstanceOf($this->schedulerClass, $this->scheduler->everyOtherWeek()); | ||
$this->assertEquals($this->scheduler->getSchedule(), '0 0 '.Scheduler::ANY.' '.Scheduler::ANY.' 0'); | ||
} | ||
|
||
public function testEveryOtherWeekOdd() | ||
{ | ||
$carbon = m::mock(); | ||
$carbon->shouldReceive('now')->andReturn($carbon); | ||
$carbon->weekOfYear = 33; | ||
App::instance('Carbon', $carbon); | ||
|
||
$this->assertInstanceOf($this->schedulerClass, $this->scheduler->everyOtherWeek()); | ||
$this->assertEquals($this->scheduler->getSchedule(), '0 0 31 2 '.Scheduler::ANY); | ||
} | ||
|
||
public function testWeekly() | ||
{ | ||
$this->assertInstanceOf($this->schedulerClass, $this->scheduler->weekly()); | ||
|
@@ -68,6 +91,12 @@ public function testHourly() | |
$this->assertEquals($this->scheduler->getSchedule(), '0 '.Scheduler::ANY.' '.Scheduler::ANY.' '.Scheduler::ANY.' '.Scheduler::ANY); | ||
} | ||
|
||
public function testNever() | ||
{ | ||
$this->assertInstanceOf($this->schedulerClass, $this->scheduler->never()); | ||
$this->assertEquals($this->scheduler->getSchedule(), '0 0 31 2 '.Scheduler::ANY); | ||
} | ||
|
||
public function testMinutes() | ||
{ | ||
$minutes = 15; | ||
|