mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 08:30:04 +01:00
MDL-48377 forum: do not swallow spaces in notification emails
This commit is contained in:
parent
ca0e301c7b
commit
28c0c4af5d
@ -762,7 +762,7 @@ function forum_cron() {
|
||||
$a->courseshortname = $shortname;
|
||||
$a->forumname = $cleanforumname;
|
||||
$a->subject = format_string($post->subject, true);
|
||||
$postsubject = html_to_text(get_string('postmailsubject', 'forum', $a));
|
||||
$postsubject = html_to_text(get_string('postmailsubject', 'forum', $a), 0);
|
||||
$posttext = forum_make_mail_text($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false,
|
||||
$replyaddress);
|
||||
$posthtml = forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto,
|
||||
|
@ -122,14 +122,15 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
*
|
||||
* @param stdClass $forum The forum to post in
|
||||
* @param stdClass $author The author to post as
|
||||
* @param array $fields any other fields in discussion (name, message, messageformat, ...)
|
||||
* @param array An array containing the discussion object, and the post object
|
||||
*/
|
||||
protected function helper_post_to_forum($forum, $author) {
|
||||
protected function helper_post_to_forum($forum, $author, $fields = array()) {
|
||||
global $DB;
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_forum');
|
||||
|
||||
// Create a discussion in the forum, and then add a post to that discussion.
|
||||
$record = new stdClass();
|
||||
$record = (object)$fields;
|
||||
$record->course = $forum->course;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum->id;
|
||||
@ -810,4 +811,29 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
$this->assertRegExp('/Reply-To: moodlemoodle123\+[^@]*@example.com/', $message->header);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_long_subject() {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
// Create a course, with a forum.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
|
||||
$options = array('course' => $course->id, 'forcesubscribe' => FORUM_FORCESUBSCRIBE);
|
||||
$forum = $this->getDataGenerator()->create_module('forum', $options);
|
||||
|
||||
// Create a user enrolled in the course as student.
|
||||
list($author) = $this->helper_create_users($course, 1);
|
||||
|
||||
// Post a discussion to the forum.
|
||||
$subject = 'This is the very long forum post subject that somebody was very kind of leaving, it is intended to check if long subject comes in mail correctly. Thank you.';
|
||||
$a = (object)array('courseshortname' => $course->shortname, 'forumname' => $forum->name, 'subject' => $subject);
|
||||
$expectedsubject = get_string('postmailsubject', 'forum', $a);
|
||||
list($discussion, $post) = $this->helper_post_to_forum($forum, $author, array('name' => $subject));
|
||||
|
||||
// Run cron and check that the expected number of users received the notification.
|
||||
$messages = $this->helper_run_cron_check_count($post, 1);
|
||||
$message = reset($messages);
|
||||
$this->assertEquals($author->id, $message->useridfrom);
|
||||
$this->assertEquals($expectedsubject, $message->subject);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user