From 3458e332dae1bc07ddd8ee5461a6804a80803e54 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 12 Aug 2019 20:43:21 +0300 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiIntegrationTestCase.php | 3 +++ tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 ); -- 2.20.1