Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-17542

Test Framework can be exited unexpectedly

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0.0-a1
    • 4.0.0-a1, 4.0.0-a2, 4.1.0-a1, 4.0.0-b1
    • Test Suite
    • None

      Since updating to PHPUnit 10, any tests that run phpBB code that can lead to phpBB's exit_handler() will now end test execution. There will be no errors. Tests will be marked as passing, even though not all tests completed. Here is an example

      In PHPUnit 9, if the exit_handler was run, PHPUnit would not exit, but instead trigger an error code.

      Tests could then, for example, test Ajax based JSON stuff that uses phpBB's json_response->send() and in your tests you would just expect a trigger error as validation.

      This no longer happens in PHPUnit 10. But because the exit_handler now has events in it, anyone running tests that will go through the exit handler need to mock the dispatcher. That also means we can update the dispatcher to set the $exit_handler_override variable in the exit handler to true, so that we return instead of exit script execution.

      That also means unit testing that was testing ajax stuff, for example, can now expect 
      $this->expectOutputString("json response string")

            MattF Matt Friedman
            MattF Matt Friedman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: