phpunit: Replace APC with HashBagOStuff during a test
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 24 Sep 2015 12:23:15 +0000 (13:23 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 24 Sep 2015 12:24:53 +0000 (13:24 +0100)
* Ensures values don't survive the unit test run.
* Ensures a clean state for each test.

Change-Id: I94e1ac14096fb4c4071fe9960d9465e60f27a89d

tests/phpunit/MediaWikiTestCase.php

index 7dc7027..49c7ad3 100644 (file)
@@ -103,6 +103,12 @@ 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.
+               ObjectCache::$instances['apc'] =
+               ObjectCache::$instances['xcache'] =
+               ObjectCache::$instances['wincache'] = new HashBagOStuff;
+
                $needsResetDB = false;
 
                if ( $this->needsDB() ) {