コード例 #1
0
 protected function get_local_timestamp(ActionScheduler_Action $action, DateTime $date = NULL)
 {
     $next = is_null($date) ? $action->get_schedule()->next() : $date;
     if (!$next) {
         throw new InvalidArgumentException(__('Invalid schedule. Cannot save action.', 'action-scheduler'));
     }
     $next->setTimezone($this->get_local_timezone());
     return $next->format('Y-m-d H:i:s');
 }
コード例 #2
0
 public function test_execute()
 {
     $mock = new MockAction();
     $random = md5(rand());
     add_action($random, array($mock, 'action'));
     $action = new ActionScheduler_Action($random, array($random));
     $action->execute();
     remove_action($random, array($mock, 'action'));
     $this->assertEquals(1, $mock->get_call_count());
     $events = $mock->get_events();
     $event = reset($events);
     $this->assertEquals($random, reset($event['args']));
 }
コード例 #3
0
 protected function schedule_next_instance(ActionScheduler_Action $action)
 {
     $next = $action->get_schedule()->next(new DateTime());
     if ($next) {
         $this->store->save_action($action, $next);
     }
 }
コード例 #4
0
 protected function schedule_next_instance(ActionScheduler_Action $action)
 {
     $next = $action->get_schedule()->next(as_get_datetime_object());
     if ($next) {
         $this->store->save_action($action, $next);
     }
 }