Clear DeferredUpdates state via setUp()
authorErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 3 Nov 2014 21:40:49 +0000 (13:40 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Mon, 3 Nov 2014 21:43:53 +0000 (13:43 -0800)
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

index 8bcfee0..95d3c40 100644 (file)
@@ -223,6 +223,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        $this->db->ignoreErrors( false );
                }
 
+               DeferredUpdates::clearPendingUpdates();
+
                wfProfileOut( __METHOD__ );
        }