This is a followup of
MDL-71036 (upgrade to PHPUnit 9), where given moodle's naming standards for test files and test classes, we have lost the possibility of executing phpunit by file name.
Extracted from the summary comment:
... PHPUnit 9 comes with a new (double) restriction. Basically, to be able to continue running tests by name, these 2 conditions must be fulfilled (see #4105 for more information):
a) The test file cannot have multiple test cases (we have
MDL-37655since ages ago about that).
b) The test file and the test class name must match (this issue).
And, while a) doesn't hurt us much (say we have only a a dozen of files needing to split), b) hurts us completely, for every test file. Because our current rules are:
- xxxx_test.php for the files.
- [component]_xxxx_testcase for the classname.
And they, obviously, break the "name-matching" condition commented in b).
Basically, there are 4 possibilities:
- We do nothing, won't be able to run tests by filename anymore.
- We modify all the file names to match the test names (aka, "lib/tests/core_moodlelib_testcase.php" will run the "core_moodlelib_testcase" testcase). Will require to change suites and other stuff (not expecting all files to be "_test.php" finished") and will make backports tricker.
- We modify all the test case names (aka, "lib/tests/moodlelib_test.php" will run the "moodlelib_test" testcase). Easier and backportable tests (but because of the different class name line).
- We invent any other new naming schema and apply for it codebase-wide.
Again, note that this issue is only to be able to run tests by file name. Everything else (whole runs, filters, suites, custom config...) continue working perfectly.
So, let's decide one of the (1-4) options above and go for it:
- TODO: Perform the agreed change (if any).
- TODO: Amend documentation about the new naming schema to follow (if any).
- TODO: Create a new check (or sniff) to get the matching names validated. Surely with level = warning.