Skip to content

Commit

Permalink
MDL-71036 phpunit: Remove custom autoloader
Browse files Browse the repository at this point in the history
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see sebastianbergmann/phpunit#4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
sebastianbergmann/phpunit#4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
  • Loading branch information
stronk7 committed Mar 11, 2021
1 parent 8a3663b commit be30af0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 206 deletions.
1 change: 0 additions & 1 deletion lib/phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

require_once(__DIR__.'/bootstraplib.php');
require_once(__DIR__.'/../testing/lib.php');
require_once(__DIR__.'/classes/autoloader.php');

if (isset($_SERVER['REMOTE_ADDR'])) {
phpunit_bootstrap_error(1, 'Unit tests can be executed only from command line!');
Expand Down
203 changes: 0 additions & 203 deletions lib/phpunit/classes/autoloader.php

This file was deleted.

3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
beStrictAboutOutputDuringTests="true"
testSuiteLoaderClass="phpunit_autoloader"
>

<php>
Expand Down Expand Up @@ -45,7 +44,7 @@
</testsuite>
<testsuite name="core_testsuite">
<directory suffix="_test.php">lib/tests</directory>
<directory suffix="_test.php">lib/ajax/tests</directory>
<!-- <directory suffix="_test.php">lib/ajax/tests</directory> -->
</testsuite>
<testsuite name="core_favourites_testsuite">
<directory suffix="_test.php">favourites/tests</directory>
Expand Down

0 comments on commit be30af0

Please sign in to comment.