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

Moodle Quiz Engine - assertTag issues a warning if tag is not found

    XMLWordPrintable

Details

    Description

      Hi,

      As I am currently developing a new question type, I just stumble upon a small issue that if corrected will be helpful for developers.

      The issue is in base_testcase.php (https://github.com/moodle/moodle/blob/master/lib/phpunit/classes/base_testcase.php#L58)

      If $tags is false, i.e. we don't find the node, then count($tags) results in an error. Preventing the following assertion to display the origin of the issue.

      If we write instead something like:

      $matched = ($tags && count($tags)) && $tags[0] instanceof DOMNode;

      It then does not raise an exception and we can see the full assertion message. Seem that it is still the case on Moodle 4.0.

      Attachments

        Issue Links

          Activity

            People

              lmdavid Laurent DAVID
              lmdavid Laurent DAVID
              Tim Hunt Tim Hunt
              Victor Déniz Falcón Victor Déniz Falcón
              CiBoT CiBoT
              Safat Shahin, Tim Hunt, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                8/Nov/21

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 3 minutes
                  1h 3m