Skip to content

Unit test test_email_certificates_sitehome relies on implicit ordering #715

@bwalkerl

Description

@bwalkerl

I've seen examples of the test_email_certificates_sitehome failing sporadically because of the order the emails were sent. This has been and hard to replicate consistently. This was found using postgress 17 on the MOODLE_404_STABLE branch and Moodle 4.5.

1) mod_customcert\email_certificate_task_test::test_email_certificates_sitehome
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'[email protected]'
+'[email protected]'

In my testing I saw that the siteadmin email can be sent either before or after the student emails, which affects the result of the test. This may be related to the ordering returned from get_users_by_capability.

$this->assertEquals($CFG->noreplyaddress, $emails[1]->from);
$this->assertEquals($user1->email, $emails[1]->to);
$this->assertEquals($CFG->noreplyaddress, $emails[2]->from);
$this->assertEquals($user2->email, $emails[2]->to);

I'm not sure why this is an issue when the student ordering isn't, but either way the test should be updated to not rely on ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions