Skip to content

Commit 661ffba

Browse files
committed
fix phpunit test step email
1 parent d270e52 commit 661ffba

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

step/email/lib.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function post_processing_bulk_operation() {
118118
['instanceid' => $step->id,
119119
'touser' => $user->id, ]);
120120

121-
$parsedsettings = $this->replace_placeholders($settings, $user, $step->id, $mailentries);
121+
$parsedsettings = $this->replace_placeholders($settings, $user, $mailentries);
122122
$subject = $parsedsettings['subject'];
123123
$content = $parsedsettings['content'];
124124
$contenthtml = $parsedsettings['contenthtml'];
@@ -148,14 +148,13 @@ public function post_processing_bulk_operation() {
148148
/**
149149
* Replaces certain placeholders within the mail template.
150150
* @param string[] $strings array of mail templates.
151-
* @param core_user $user User object.
152-
* @param int $stepid Id of the step instance.
151+
* @param \stdClass $user User object.
153152
* @param array[] $mailentries Array consisting of course entries from the database.
154153
* @return string[] array of mail text.
155154
* @throws \dml_exception
156155
* @throws \moodle_exception
157156
*/
158-
public function replace_placeholders($strings, $user, $stepid, $mailentries) {
157+
public function replace_placeholders($strings, $user, $mailentries) {
159158
global $CFG;
160159

161160
$patterns = [];

step/email/tests/lib_test.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ public function test_replace_placeholders(): void {
5050
$course1 = $this->getDataGenerator()->create_course(['fullname' => 'Course 1', 'shortname' => 'C1']);
5151
$course2 = $this->getDataGenerator()->create_course(['fullname' => 'Course 2', 'shortname' => 'C2']);
5252
$lib = new email();
53-
$response = $lib->replace_placeholders([
53+
$response = $lib->replace_placeholders(
54+
[
5455
"##firstname##\n##lastname##\n##courses##\n##shortcourses##",
5556
"##firstname##<br>##lastname##<br>##courses-html##<br>##shortcourses-html##",
56-
], $user1, 0, [(object) ['courseid' => $course1->id], (object) ['courseid' => $course2->id]]);
57+
],
58+
$user1,
59+
[
60+
(object) ['courseid' => $course1->id],
61+
(object) ['courseid' => $course2->id],
62+
]
63+
);
5764
$this->assertCount(2, $response);
58-
$this->assertEquals("Jane\nDoe\nCourse 1\nCourse 2\nC1\nC2", $response[0]);
65+
$this->assertEquals("Jane\nDoe\nCourse 1\r\nCourse 2\nC1\r\nC2", $response[0]);
5966
$this->assertEquals("Jane<br>Doe<br>Course 1<br>Course 2<br>C1<br>C2", $response[1]);
6067
}
6168
}

0 commit comments

Comments
 (0)