/** * Run the forum cron, and check that the specified post was sent the * specified number of times. * * @param integer $expected The number of times that the post should have been sent * @return array An array of the messages caught by the message sink */ protected function helper_run_cron_check_count($expected, $messagecount, $mailcount) { if ($expected === 0) { $this->expectOutputRegex('/(Email digests successfully sent to .* users.){0}/'); } else { $this->expectOutputRegex("/Email digests successfully sent to {$expected} users/"); } hsuforum_cron(); // Now check the results in the message sink. $messages = $this->helper->messagesink->get_messages(); // There should be the expected number of messages. $this->assertEquals($messagecount, count($messages)); // Now check the results in the mail sink. $messages = $this->helper->mailsink->get_messages(); // There should be the expected number of messages. $this->assertEquals($mailcount, count($messages)); return $messages; }
/** * Run forum cron. */ public function execute() { global $CFG; require_once $CFG->dirroot . '/mod/hsuforum/lib.php'; hsuforum_cron(); }