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

Make it possible to do unit tests of code that calls error()

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: General
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      You can't do unit tests for functions which call error() because this calls 'exit' and kills the test.

      There is already a constant defined when unit tests are being run so I intend using this to make error() throw an exception if called during the unit test. The exception includes the error message and URL if supplied, so it is possible to test that these are correct as part of the test.

      Because it uses exceptions (PHP5), this change is for Moodle 2 only.

        Attachments

          Activity

            People

            Assignee:
            quen Sam Marshall
            Reporter:
            quen Sam Marshall
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10