Clear test user registry between tests
authorAryeh Gregor <ayg@aryeh.name>
Mon, 12 Aug 2019 17:43:21 +0000 (20:43 +0300)
committerAryeh Gregor <ayg@aryeh.name>
Wed, 14 Aug 2019 07:27:21 +0000 (10:27 +0300)
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
tests/phpunit/includes/rcfeed/RCFeedIntegrationTest.php

index 07d135d..93a596a 100644 (file)
@@ -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
index 871ea91..59fe401 100644 (file)
@@ -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
                                );