From 49cfcf3715822b66c7cf3ab0f3771910ad8b69c1 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Mon, 3 Nov 2014 13:40:49 -0800 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 2 ++ 1 file changed, 2 insertions(+) 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__ ); } -- 2.20.1