From: Aryeh Gregor Date: Mon, 12 Aug 2019 17:43:21 +0000 (+0300) Subject: Clear test user registry between tests X-Git-Tag: 1.34.0-rc.0~721^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=3458e332dae1bc07ddd8ee5461a6804a80803e54;p=lhc%2Fweb%2Fwiklou.git Clear test user registry between tests Otherwise User members will wind up retaining stale references to services. The more things move to services, the more state we need to reset between tests to avoid subtle and confusing test failures! TestUsers can't be created if the DB prefix is not either unittest_ or ut_, which caused failures in RCFeedIntegrationTest.php with this change now that it was trying to create a new TestUser. Fix is to set the prefix to one of those two instead of empty. Change-Id: I41f87e1acffe94361748ef4ab69c290de587e6be --- diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index 07d135de8d..93a596a620 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -635,6 +635,9 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { } } + // Clear any cached test users so they don't retain references to old services + TestUserRegistry::clear(); + // Re-enable any disabled deprecation warnings MWDebug::clearLog(); // Restore mw globals diff --git a/tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php b/tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php index 871ea91196..59fe4012b6 100644 --- a/tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php +++ b/tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php @@ -17,7 +17,7 @@ class RCFeedIntegrationTest extends MediaWikiTestCase { 'wgServerName' => 'example.org', 'wgScriptPath' => '/w', 'wgDBname' => 'example', - 'wgDBprefix' => '', + 'wgDBprefix' => $this->dbPrefix(), 'wgRCFeeds' => [], 'wgRCEngines' => [], ] ); @@ -57,7 +57,7 @@ class RCFeedIntegrationTest extends MediaWikiTestCase { 'server_url' => 'https://example.org', 'server_name' => 'example.org', 'server_script_path' => '/w', - 'wiki' => 'example', + 'wiki' => 'example-' . $this->dbPrefix(), ] ), $line );