private function process_messages(DateTime $currentTime)
 {
     $number_of_messages = $this->getNumberOfAutoresponderMessages();
     $number_of_iterations = ceil($number_of_messages / $this->autoresponder_messages_loop_iteration_size());
     $this->recordAutoresponderProcessHeartbeat();
     for ($iter = 0; $iter < $number_of_iterations; $iter++) {
         $this->recordAutoresponderProcessHeartbeat();
         $start = $iter * $this->autoresponder_messages_loop_iteration_size();
         $messages = AutoresponderMessage::getAllMessages($start, $this->autoresponder_messages_loop_iteration_size());
         $this->recordAutoresponderProcessHeartbeat();
         foreach ($messages as $message) {
             $this->deliver_message($message, $currentTime);
         }
     }
     $this->recordAutoresponderProcessHeartbeat();
 }
 public function testFetchingPagedListOfAutoresponders()
 {
     global $wpdb;
     $autoresponder1_id = $this->createAAutoresponderWithRandomName();
     $numberOfMessagesInAutoresponderOne = 100;
     $autoresponderMessagesIds = $this->createMessagesForAutoresponder($numberOfMessagesInAutoresponderOne, $autoresponder1_id);
     $messages = AutoresponderMessage::getAllMessages(20, 30);
     $this->assertEquals(30, count($messages));
     $received_ids = $this->getMessageIds($messages);
     $expected = array_slice($autoresponderMessagesIds, 20, 30);
     $intersect = array_intersect($received_ids, $expected);
     $this->assertEquals(count($intersect), count($expected));
 }