This commit moves the presets subsystem to a location within the admin
folder, which is more appropriate given its purpose and reduces
developer frustration with tab completion of the admin directory.
While testing the changed unit tests one by one, the
payment/tests/helper_test.php was failing because of a mismatch
between the dataProvider data and the param type.
That made me think why that error was not popping in complete runs
and the answer is that the new (3.10) subsystem is not in the
phpunit.xml.dist file.
Hence, adding it and fixing the dataProvider mismatch.
Finally, it has been detected that some old ICU versions (< 62)
have an incorrect behaviour, not adding the required non-breaking
white-space between the currency abbreviation and the value. So
we are skipping some payment tests if that's found.
Basically switch to 2-space indenting and small tweaks to comments,
so both the main phpunit.xml file and also the individual components
ones, all them based in the dist one will be consistent.
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 https://github.com/sebastianbergmann/phpunit/issues/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
https://github.com/sebastianbergmann/phpunit/issues/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.
That custom printer was using some hacks to be able to intercept
configuration switches, reflection and other tricks to be able to
print the:
To re-run:
vendor/bin/phpunit --verbose "core_setuplib_testcase" lib/tests/setuplib_test.php
line on every failed/exceptional/skipped test. After some internal
discussion it was agreed that the normal phpunit output:
1) core_setuplib_testcase::test_localcachedir
Time is lower that allowed start value
Failed asserting that 1601976686 is equal to 1601976687 or is greater than 1601976687.
/var/www/html/lib/phpunit/classes/advanced_testcase.php:446
/var/www/html/lib/tests/setuplib_test.php:170
/var/www/html/lib/phpunit/classes/advanced_testcase.php:80
has already all the information at hand about how to rerun a test:
- vendor/bin/phpunit lib/tests/setuplib_test.php
- vendor/bin/phpunit --filter core_setuplib_testcase::test_localcachedir
- vendor/bin/phpunit --filter ::test_localcachedir
- vendor/bin/phpunit --testsuite componentname_testsuite
- vendor/bin/phpunit --config <<compoenent directory>>
- use --cache-result to get failed tests rerun with ease.
- ...
So better, let's use standard phpunit output and done. Also, note that,
with the upgrade to phpunit 8.5, the printer was not working correctly
any more, causing some switches, like --verbose ... to be ignored. Sure
it could have been fixed but, as commented above, no real need for all
that "parapheranlia" to print the rerun information.
It can be enabled if desired from CLI using the --cache-result
option (or modifying the phpunit.xml cacheResult to true).
That will create the .phpunit.result.cache files that,
later, can be used to easily repeat failed (defects) tests or
run the slow ones first and more. See the --order-by option
to know more about all the available criteria. For example:
./vendor/bin/phpunit --order-by=defects --stop-on-defect
(will run all the failed ones first, stopping on problem, useful
for TDD and other scenarios, not so much for complete runs or CI).
Also, added to .gitignore so they won't be committed ever.
This commit is part of work on Custom fields API,
to minimize commit history in moodle core the work of a team of developers was split
into several commits with different authors but the authorship of individual
lines of code may be different from the commit author.
This change also add fail-on-risky to travis to help pick these up, and
verbosity too.
We only fail on risky during Travis and not during normal output because
developers may want to debug tests.
Introducing both APIs in moodle along with:
- search_box widget to add a tiny search box
- admin settings with setup steps helper
- cache for search results
- template for a search result
- php unit stuff
Many thanks to Tomasz Muras, Prateek Sachan and Daniel Neis for their contributions, for starting this development
and for pushing for it to be completed. Also thanks to other contributors: Jonathan Harker and eugeneventer.