Reset services before every test
authorTim Starling <tstarling@wikimedia.org>
Thu, 30 Aug 2018 11:35:25 +0000 (21:35 +1000)
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>
Mon, 3 Sep 2018 16:38:58 +0000 (16:38 +0000)
commit532210719184db1d0449b09bfded13cb1dfc1759
treeb863ffcac978c14a724e3a5772188a64faaaf0f1
parent2d5b2f0f6a835446aab05c2009f785c430d25391
Reset services before every test

Trying to avoid resetting services introduces a lot of complexity and
several bugs. We were doing a reset for 70% of @group Database tests
anyway.

Instead:

* Reset services at the start of MediaWikiTestCase::run().
* Capture the actual original service container instead of making a
  special shared service container.
* The test-isolated local service container can now only be initialised
  non-statically. Revert the recent conversion of overrideMwServices()
  to static.
* Store a reference to the local service container in the test case
  object. In MediaWikiTestCase, always use the original or local service
  container directly, to avoid confusion about which one is active at
  the time.
* Remove a lot of unnecessary teardown
* Always call ServiceContainer::destroy() before forceGlobalInstance()
  since the memory is not otherwise freed.

Change-Id: I4a17c1c7ec92c14e3bc471f0216473ebe19477b9
tests/common/TestSetup.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/PrefixSearchTest.php
tests/phpunit/includes/Storage/PageUpdaterTest.php
tests/phpunit/includes/search/SearchEnginePrefixTest.php
tests/phpunit/phpunit.php
tests/phpunit/structure/SpecialPageFatalTest.php
tests/phpunit/tests/MediaWikiTestCaseTest.php