From 74433a3ca83e8dae2c347d039932ea5e47ba3665 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 25 Sep 2015 05:51:01 +0100 Subject: [PATCH] phpunit: Set $wgMainStash to 'hash' during test execution Also clean up the other cache settings to match their order as defined in DefaultSettings.php. Don't disable MessageCacheType, ParserCacheType etc. This could prevent bugs from happening during tests. They are enabled by default in MediaWiki with CACHE_ANYTHING. At least let them use 'hash' during tests to resemble a more realistic environment. Change-Id: Id9edf33c600db3ac4d837e1674a8eb2f5363a4f8 --- tests/phpunit/MediaWikiTestCase.php | 4 ++-- tests/phpunit/phpunit.php | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 73c40662b4..bd30397181 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -103,8 +103,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { */ ObjectCache::$instances[CACHE_DB] = new HashBagOStuff; - // Sandbox APC by replacing with in-process hash cache instead. - // Ensures tests are removed between tests. + // Sandbox APC by replacing with in-process hash instead. + // Ensures values are removed between tests. ObjectCache::$instances['apc'] = ObjectCache::$instances['xcache'] = ObjectCache::$instances['wincache'] = new HashBagOStuff; diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 587d6d0c2c..af924a0c47 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -66,11 +66,21 @@ class PHPUnitMaintClass extends Maintenance { // wfWarn should cause tests to fail $wgDevelopmentWarnings = true; + // Make sure all caches and stashes are either disabled or use + // in-process cache only to prevent tests from using any preconfigured + // cache meant for the local wiki from outside the test run. + // See also MediaWikiTestCase::run() which mocks CACHE_DB and APC. + + // Disabled in DefaultSettings, override local settings + $wgMainWANCache = $wgMainCacheType = CACHE_NONE; - $wgMainWANCache = CACHE_NONE; - $wgMessageCacheType = CACHE_NONE; - $wgParserCacheType = CACHE_NONE; - $wgLanguageConverterCacheType = CACHE_NONE; + // Uses CACHE_ANYTHING in DefaultSettings, use hash instead of db + $wgMessageCacheType = + $wgParserCacheType = + $wgSessionCacheType = + $wgLanguageConverterCacheType = 'hash'; + // Uses db-replicated in DefaultSettings + $wgMainStash = 'hash'; $wgUseDatabaseMessages = false; # Set for future resets -- 2.20.1