From: Erik Bernhardson Date: Mon, 3 Nov 2014 21:40:49 +0000 (-0800) Subject: Clear DeferredUpdates state via setUp() X-Git-Tag: 1.31.0-rc.0~13406^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=49cfcf3715822b66c7cf3ab0f3771910ad8b69c1;p=lhc%2Fweb%2Fwiklou.git Clear DeferredUpdates state via setUp() Best practices for phpunit say 'more setUp, less tearDown' which typically means that tests are not responsible for cleaning up after themselves, rather tests are in charge of setting the world up exactly as they expect it. Part of this expectation is that mediawiki does not maintain state between tests. This patch clears DeferredUpdates from MediaWikiTestCase::setUp() because it has internal global state. This prevents state from leaking between test cases. Bug: 72922 Change-Id: I57e6e89aa51c78bbf9d7f5151122b9e267d1a03e --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 8bcfee0ce7..95d3c40f20 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -223,6 +223,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->db->ignoreErrors( false ); } + DeferredUpdates::clearPendingUpdates(); + wfProfileOut( __METHOD__ ); }