public function test_next()
 {
     $now = time();
     $start = $now - 30;
     $schedule = new ActionScheduler_IntervalSchedule(new DateTime("@{$start}"), MINUTE_IN_SECONDS);
     $this->assertEquals($start, $schedule->next()->format('U'));
     $this->assertEquals($now + MINUTE_IN_SECONDS, $schedule->next(new DateTime())->format('U'));
     $this->assertEquals($start, $schedule->next(new DateTime("@{$start}"))->format('U'));
 }
 public function test_next_instance_of_action()
 {
     $store = new ActionScheduler_wpPostStore();
     $runner = new ActionScheduler_QueueRunner($store);
     $random = md5(rand());
     $schedule = new ActionScheduler_IntervalSchedule(new DateTime('12 hours ago'), DAY_IN_SECONDS);
     $action = new ActionScheduler_Action($random, array(), $schedule);
     $store->save_action($action);
     $runner->run();
     $claim = $store->stake_claim(10, new DateTime(DAY_IN_SECONDS - 60 . ' seconds'));
     $this->assertCount(0, $claim->get_actions());
     $claim = $store->stake_claim(10, new DateTime(DAY_IN_SECONDS . ' seconds'));
     $actions = $claim->get_actions();
     $this->assertCount(1, $actions);
     $action_id = reset($actions);
     $new_action = $store->fetch_action($action_id);
     $this->assertEquals($random, $new_action->get_hook());
     $this->assertEquals($schedule->next(new DateTime()), $new_action->get_schedule()->next(new DateTime()));
 }