After some tests, it seems that we can safely cover
phpunit_util::reset_all_data() executing it within
own basic_test self tests.
That way we can confirm that the reset code is doing its job
and detecting unexpected changes at various levels (database,
globals, ...).
Note that, in order to catch the E_USER_WARNINGS, for PHPUnit 9.6
and up, we have to convert them to exceptions, because the notice/
warning/error expectations have been deprecated and will be removed
in PHPUnit 10. So we are using a trick, already used also by
advanced_test. And, no matter that we are repeating the trick
a few times, that's ok in order to have all its uses controlled.
The changes here are heterogeneous:
- Include stuff that is not available (other test has included it).
Sometimes local to a unit test, others in setupBeforeClass() or
globally, ... depends on every case.
- Rename some tests (namespaces, test name, ...) towards getting it
running.
- Amend small bits here and there.
Important note: I've left any "cosmetic" warning out from the
changes, only a few errors (like long array syntax) have been fixed.
There are a few tests in core that are commented since the
beginning. That's not useful at all, so with this commit we
are un-commenting them instead.
Note that this is an initial step to have them back with skipped
outcome. Later in this issue we'll decide about to keep them or
completely remove them (each test can have a different outcome).
This workflow just finds all the individual
tests available in core (all the test_ methods
in _test.php file) and runs them one by one,
with a total isolation, because each one is
executed by a different PHPUnit invocation..
Any test ending with error, will be reported
as part of the output.
Note that we are not using PHPUnit's own
isolation here, just running them one by one.
The default option "ASSIGN_ATTEMPT_REOPEN_METHOD_NONE" for the
"attemptreopenmethod" setting, which disallows multiple attempts at the
assignment, has been removed. This option was unnecessary because
limiting attempts to 1 through the "maxattempts" setting achieves the
same behavior.
Apart from removing this setting option (including removal of usage in
code and updating existing data in the DB), these changes include:
- Introducing a more effective progressive disclosure by allowing the
"maxattempts" setting to control the visibility of the
"attemptreopenmethod" setting in the form.
- String improvements to the labels and help text for the "maxattempts"
and "attemptreopenmethod" settings
- Changing the default value of the "maxattempts" setting from
"unlimited" to "1"