| 1 | <?php |
||
| 7 | class ActionScheduler_IntervalSchedule_Test extends ActionScheduler_UnitTestCase { |
||
| 8 | public function test_creation() { |
||
| 9 | $time = as_get_datetime_object(); |
||
| 10 | $schedule = new ActionScheduler_IntervalSchedule($time, HOUR_IN_SECONDS); |
||
| 11 | $this->assertEquals( $time, $schedule->next() ); |
||
| 12 | } |
||
| 13 | |||
| 14 | public function test_next() { |
||
| 15 | $now = time(); |
||
| 16 | $start = $now - 30; |
||
| 17 | $schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object("@$start"), MINUTE_IN_SECONDS ); |
||
| 18 | $this->assertEquals( $start, $schedule->next()->getTimestamp() ); |
||
| 19 | $this->assertEquals( $now + MINUTE_IN_SECONDS, $schedule->next(as_get_datetime_object())->getTimestamp() ); |
||
| 20 | $this->assertEquals( $start, $schedule->next(as_get_datetime_object("@$start"))->getTimestamp() ); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function test_is_recurring() { |
||
| 24 | $start = time() - 30; |
||
| 25 | $schedule = new ActionScheduler_IntervalSchedule( as_get_datetime_object("@$start"), MINUTE_IN_SECONDS ); |
||
| 26 | $this->assertTrue( $schedule->is_recurring() ); |
||
| 27 | } |
||
| 28 | } |
||
| 29 |