1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

MDL-47808 mod_forum: Correct maxeditingtime for unit tests

The maxeditingtime needs to be a negative value for unit tests to ensure
that the messages are actually sent out.

Whilst fixing this I also discovered that the create_discussion part of the
generator also creates the first post.
This commit is contained in:
Andrew Nicols 2014-10-23 08:43:29 +08:00
parent 718f179c22
commit 555837c5d4

@ -55,9 +55,9 @@ class mod_forum_mail_testcase extends advanced_testcase {
$messages = $helper->mailsink->get_messages();
$this->assertEquals(0, count($messages));
// Forcibly reduce the maxeditingtime to a one second to ensure that
// messages are sent out.
$CFG->maxeditingtime = 1;
// Forcibly reduce the maxeditingtime to a second in the past to
// ensure that messages are sent out.
$CFG->maxeditingtime = -1;
// Ensure that we don't prevent e-mail as this will cause unit test failures.
$CFG->noemailever = false;
@ -107,6 +107,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
* @param array An array containing the discussion object, and the post object
*/
protected function helper_post_to_forum($forum, $author) {
global $DB;
$generator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
// Create a discussion in the forum, and then add a post to that discussion.
@ -116,13 +117,8 @@ class mod_forum_mail_testcase extends advanced_testcase {
$record->forum = $forum->id;
$discussion = $generator->create_discussion($record);
$record = new stdClass();
$record->course = $forum->course;
$record->userid = $author->id;
$record->forum = $forum->id;
$record->discussion = $discussion->id;
$record->mailnow = 1;
$post = $generator->create_post($record);
// Retrieve the post which was created by create_discussion.
$post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
return array($discussion, $post);
}