Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-80713

PHPUnit: Create method to get the correct messages and emails for a specific component

XMLWordPrintable

    • 2
    • Team Hedgehog 2023 Review 4, Team Hedgehog 2024 Sprint 1.1

      I'm getting some PHPUnit failures while implementing a new feature.
      After investigating, I saw that many places where PHPUnit tests are using something like this

      $messages = $messagesink->get_messages();
      $message = reset($messages);
      // Do the check for message content.

      Most of the tests assume that we have only one message/email at that time or the expected message of the test is always the first one.
      Which is not always correct.

      For example: You're doing the test for mod_forum.
      The test creates one message for mod_forum component and the other component also creates one message.

      At this time $messagesink->get_messages(); will return 2 messages and $message = reset($messages) does not always return the message for mod_forum.

       

      We should create a new method like

      get_messages_by_component(string $component)

      By that way, we can get the correct messages for the component we're doing the test.

            huongn@moodle.com Huong Nguyen
            huongn@moodle.com Huong Nguyen
            Stevani Andolo Stevani Andolo
            Simey Lameze Simey Lameze
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 4 hours, 47 minutes
                1d 4h 47m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.