From f89d2ebcfc1da66b14edb784172b3e2ddcbf5b28 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sat, 29 Jul 2023 18:30:34 +0200 Subject: [PATCH] MDL-xxxxx phpunit: Update configuration file to version 10 This comes with a good number of changes: 1. The convertXXXXToExceptions are gone, with notices, warnings and others not being shown by default. To mimic the previous behaviour we are enabling all these: - failOnNotice - failOnWarning - displayDetailsOnTestsThatTriggerDeprecations - displayDetailsOnTestsThatTriggerErrors - displayDetailsOnTestsThatTriggerNotices - displayDetailsOnTestsThatTriggerWarnings With them the behaviour is 99% the same than the previous one. Still there are some defaults that should be considered, like failing on Incomplete, Risky, Deprecation... but they were not enabled previously, so I've left them apart (not failing and not showing details). They can be enabled with a simple -v. 2. backupStaticAttributes renamed to backupStaticProperties. 3. stopOnXXX removed, because all them default to false, so no needed. 4. Added cacheDirectory (.phpunit.cache) for anybody wanting to use it via command line --cache-result option (also @ .gitignore). Also ensure that the distributed phpunit.xml files are generated pointing to it. We remove the previous .phpunit.result.cache file, because it's deprecated by https://github.com/sebastianbergmann/phpunit/issues/4599 5. Enabled beStrictAboutChangesToGlobalState , not sure about it but can help to detect cases where something is changed without noticing. 6. The section is now only to configure how coverage should be generated and evaluated. The lists of directories and files have been moved to the new section. --- .gitignore | 2 +- lib/phpunit/classes/util.php | 3 +- lib/phpunit/phpunit.xsd | 209 +++++++++++++++++------------------ phpunit.xml.dist | 23 ++-- 4 files changed, 115 insertions(+), 122 deletions(-) diff --git a/.gitignore b/.gitignore index 1f1ea578ac170..5c4a3d893485e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ CVS /.project /.buildpath /.cache -.phpunit.result.cache +.phpunit.cache phpunit.xml # Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us. composer.phar diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php index 0e0bb2d1cb678..d217fff4d9d14 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -667,9 +667,10 @@ public static function build_component_config_files() { '', $fcontents); - // fix link to schema + // Fix link to schema, bootstrap and cache directory. $level = substr_count(str_replace('\\', '/', $cpath), '/') - substr_count(str_replace('\\', '/', $CFG->dirroot), '/'); $fcontents = str_replace('lib/phpunit/', str_repeat('../', $level).'lib/phpunit/', $fcontents); + $fcontents = str_replace('.phpunit.cache', str_repeat('../', $level) . '.phpunit.cache', $fcontents); // Write the file $result = false; diff --git a/lib/phpunit/phpunit.xsd b/lib/phpunit/phpunit.xsd index 3785d21fef773..269b7a3aeb489 100644 --- a/lib/phpunit/phpunit.xsd +++ b/lib/phpunit/phpunit.xsd @@ -2,7 +2,7 @@ - This Schema file defines the rules by which the XML configuration file of PHPUnit 9.5 may be structured. + This Schema file defines the rules by which the XML configuration file of PHPUnit 10.2 may be structured. @@ -11,18 +11,48 @@ Root Element - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -32,7 +62,6 @@ - @@ -57,62 +86,19 @@ - - - - - - + - + - - - - - + - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -125,23 +111,6 @@ - - - - - - - - - - - - - - - - - @@ -164,17 +133,6 @@ - - - - - - - - - - - @@ -207,65 +165,64 @@ - + + - - - - - - - + + + + + + + + + - + - - - - - + - - + - - - - + - + + + + + + - + - @@ -279,11 +236,41 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -301,8 +288,6 @@ - - @@ -319,6 +304,12 @@ + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fd7faeecc081b..08cdaae7a7363 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,19 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="lib/phpunit/phpunit.xsd" bootstrap="lib/phpunit/bootstrap.php" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" processIsolation="false" backupGlobals="false" - backupStaticAttributes="false" + backupStaticProperties="false" cacheResult="false" - stopOnError="false" - stopOnFailure="false" - stopOnIncomplete="false" - stopOnSkipped="false" - beStrictAboutTestsThatDoNotTestAnything="false" + cacheDirectory=".phpunit.cache" + failOnNotice="true" + failOnWarning="true" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true" + beStrictAboutTestsThatDoNotTestAnything="false" > @@ -228,8 +229,8 @@ - + - +