MDL-73996 reportbuilder: Assert task log contains expected strings

* Ordering issues from \core_reportbuilder\local\helpers\schedule's
get_schedule_report_users() method won't guarantee that the expected
task log output will always be the same as user two can be fetched first
before user one which will cause the message to be sent to user two
first. So just get the task log's output string and make sure it
contains the expected log strings.
This commit is contained in:
Jun Pataleta
2022-03-03 11:09:59 +08:00
parent 350d7b9515
commit 898f3d0a82

View File

@@ -109,14 +109,17 @@ class send_schedule_test extends advanced_testcase {
// Send the schedule, catch emails in sink.
$sink = $this->redirectEmails();
$this->expectOutputRegex("/^Sending schedule: My schedule\n" .
" Sending to: " . fullname($userone) . "\n" .
" Sending to: " . fullname($usertwo) . "\n" .
"Sending schedule complete\n/"
);
ob_start();
$sendschedule = new send_schedule();
$sendschedule->set_custom_data(['reportid' => $report->get('id'), 'scheduleid' => $schedule->get('id')]);
$sendschedule->execute();
$output = ob_get_clean();
// Assert the output contains the following messages.
$this->assertStringContainsString("Sending schedule: My schedule", $output);
$this->assertStringContainsString("Sending to: " . fullname($userone), $output);
$this->assertStringContainsString("Sending to: " . fullname($usertwo), $output);
$this->assertStringContainsString("Sending schedule complete", $output);
$messages = $sink->get_messages();
$this->assertCount(2, $messages);