protected function run_cleanup()
 {
     $cleaner = new ActionScheduler_QueueCleaner($this->store);
     $cleaner->delete_old_actions();
     $cleaner->reset_timeouts();
     $cleaner->mark_failures();
 }
 public function test_do_not_reset_failed_action()
 {
     $store = new ActionScheduler_wpPostStore();
     $random = md5(rand());
     $schedule = new ActionScheduler_SimpleSchedule(new DateTime('1 day ago'));
     $created_actions = array();
     for ($i = 0; $i < 5; $i++) {
         $action = new ActionScheduler_Action($random, array($random), $schedule);
         $created_actions[] = $store->save_action($action);
     }
     $claim = $store->stake_claim(10);
     foreach ($claim->get_actions() as $action_id) {
         // simulate the first action interrupted by an uncatchable fatal error
         $store->log_execution($action_id);
         break;
     }
     add_filter('action_scheduler_timeout_period', '__return_zero');
     // delete any finished job
     $cleaner = new ActionScheduler_QueueCleaner($store);
     $cleaner->reset_timeouts();
     remove_filter('action_scheduler_timeout_period', '__return_zero');
     $new_claim = $store->stake_claim(10);
     $this->assertCount(4, $new_claim->get_actions());
     add_filter('action_scheduler_failure_period', '__return_zero');
     $cleaner->mark_failures();
     remove_filter('action_scheduler_failure_period', '__return_zero');
     $failed = $store->query_actions(array('status' => ActionScheduler_Store::STATUS_FAILED));
     $this->assertEquals($created_actions[0], $failed[0]);
     $this->assertCount(1, $failed);
 }