MDL-84733 assign: add tests of existing message behaviour

This is to prove the changes in the next two commits don't change
the behaviour.

Note, I tidied up the whitespace in some HTML lang strings.
This commit is contained in:
Tim Hunt 2025-03-14 16:05:20 +00:00
parent c1411d4a2c
commit 5b1a302374
3 changed files with 42 additions and 15 deletions

View File

@ -92,8 +92,7 @@ assignment submission for \'{$a->assignment}\'
You can see it appended to your assignment submission:
{$a->url}';
$string['assignmentmailhtml'] = '<p>{$a->grader} has posted some feedback on your
assignment submission for \'<i>{$a->assignment}</i>\'.</p>
$string['assignmentmailhtml'] = '<p>{$a->grader} has posted some feedback on your assignment submission for \'<i>{$a->assignment}</i>\'.</p>
<p>You can see it appended to your <a href="{$a->url}">assignment submission</a>.</p>';
$string['assignmentmailsmall'] = '{$a->grader} has posted some feedback on your
assignment submission for \'{$a->assignment}\' You can see it appended to your submission';
@ -268,8 +267,7 @@ for \'{$a->assignment}\' at {$a->timeupdated}
It is available here:
{$a->url}';
$string['gradersubmissionupdatedhtml'] = '{$a->username} has updated their assignment submission
for <i>\'{$a->assignment}\' at {$a->timeupdated}</i><br /><br />
$string['gradersubmissionupdatedhtml'] = '{$a->username} has updated their assignment submission for <i>\'{$a->assignment}\' at {$a->timeupdated}</i><br /><br />
It is <a href="{$a->url}">available on the web site</a>.';
$string['gradersubmissionupdatedsmall'] = '{$a->username} has updated their submission for assignment {$a->assignment}.';
$string['gradeuser'] = 'Grade {$a}';
@ -286,8 +284,7 @@ assignment submission for \'{$a->assignment}\'
You can see it appended to your assignment submission:
{$a->url}';
$string['feedbackavailablehtml'] = '{$a->username} has posted some feedback on your
assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
$string['feedbackavailablehtml'] = '{$a->username} has posted some feedback on your assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
You can see it appended to your <a href="{$a->url}">assignment submission</a>.';
$string['feedbackavailablesmall'] = '{$a->username} has given feedback for assignment {$a->assignment}';
$string['feedbackavailableanontext'] = 'You have new feedback on your
@ -296,8 +293,7 @@ assignment submission for \'{$a->assignment}\'
You can see it appended to your assignment submission:
{$a->url}';
$string['feedbackavailableanonhtml'] = 'You have new feedback on your
assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
$string['feedbackavailableanonhtml'] = 'You have new feedback on your assignment submission for \'<i>{$a->assignment}</i>\'<br /><br />
You can see it appended to your <a href="{$a->url}">assignment submission</a>.';
$string['feedbackavailableanonsmall'] = 'New feedback for assignment {$a->assignment}';
$string['feedbackplugins'] = 'Feedback plugins';
@ -580,8 +576,7 @@ $string['submissioncopiedtext'] = 'You have made a copy of your previous assignm
You can see the status of your assignment submission:
{$a->url}';
$string['submissioncopiedhtml'] = '<p>You have made a copy of your previous
assignment submission for \'<i>{$a->assignment}</i>\'.</p>
$string['submissioncopiedhtml'] = '<p>You have made a copy of your previous assignment submission for \'<i>{$a->assignment}</i>\'.</p>
<p>You can see the status of your <a href="{$a->url}">assignment submission</a>.</p>';
$string['submissioncopiedsmall'] = 'You have copied your previous assignment submission for {$a->assignment}';
$string['submissiondrafts'] = 'Require students to click the submit button';
@ -603,8 +598,7 @@ $string['submissionreceiptothertext'] = 'Your assignment submission for \'{$a->a
You can see the status of your assignment submission:
{$a->url}';
$string['submissionreceiptotherhtml'] = 'Your assignment submission for
\'<i>{$a->assignment}</i>\' has been submitted.<br /><br />
$string['submissionreceiptotherhtml'] = 'Your assignment submission for \'<i>{$a->assignment}</i>\' has been submitted.<br /><br />
You can see the status of your <a href="{$a->url}">assignment submission</a>.';
$string['submissionreceiptothersmall'] = 'Your assignment submission for {$a->assignment} has been submitted.';
$string['submissionreceipts'] = 'Send submission receipts';

View File

@ -41,7 +41,7 @@ trait mod_assign_test_generator {
* Convenience function to create a testable instance of an assignment.
*
* @param array $params Array of parameters to pass to the generator
* @return testable_assign Testable wrapper around the assign class.
* @return mod_assign_testable_assign Testable wrapper around the assign class.
*/
protected function create_instance($course, $params = [], $options = []) {
$params['course'] = $course->id;

View File

@ -1765,8 +1765,41 @@ final class locallib_test extends \advanced_testcase {
$messages = $sink->get_messages();
$this->assertEquals(1, count($messages));
$this->assertEquals(1, $messages[0]->notification);
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
// Get some bits we will need to verify the content of the message.
$assignname = $assign->get_instance()->name;
$assignurl = (new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]))->out();
$teachername = fullname($teacher);
$assignsurl = (new \moodle_url('/mod/assign/index.php', ['id' => $course->id]))->out();
$courseurl = (new \moodle_url('/course/view.php', ['id' => $course->id]))->out();
$message = $messages[0];
$this->assertEquals(1, $message->notification);
$this->assertEquals($assign->get_instance()->name, $message->contexturlname);
$this->assertEquals("$teachername has given feedback for assignment $assignname", $message->subject, );
$this->assertEquals("$course->shortname -> Assignment -> $assignname
---------------------------------------------------------------------
$teachername has posted some feedback on your
assignment submission for '$assignname'
You can see it appended to your assignment submission:
$assignurl
---------------------------------------------------------------------
",
$message->fullmessage,
);
$this->assertEquals(
'<p><font face="sans-serif"><a href="' . $courseurl . '">' . $course->shortname . '</a> ' .
'-><a href="' . $assignsurl . '">Assignment</a> ' .
'-><a href="' . $assignurl . '">' . $assignname . '</a></font></p><hr />' .
'<font face="sans-serif"><p>' . $teachername . ' has posted some feedback on your ' .
'assignment submission for \'<i>' . $assignname . '</i>\'<br /><br />' . "\n" .
'You can see it appended to your <a href="' . $assignurl .
'">assignment submission</a>.</p></font><hr />',
$message->fullmessagehtml
);
}
public function test_cron_message_includes_courseid(): void {