phpunit: factor out logic to handle globals vars

Authored by hashar on Fri, Apr 21, 11:30 AM.


phpunit: factor out logic to handle globals vars

loggingTest data providers loads $wgConf in global scope. With PHPUnit
backing up globals on each test, that slow down the test run. The class
has logic to restore the globals in the data provider so tests get run
with a clean global scope.

cirrusTest has the same need. Hence factor out global handling code to a
new PHPUnit_FrameWork_TestCase: WgConfTestCase.

Switch loggingTest to it.
Port cirrusTest.

When setting globals with setGlobals(), we want to make sure they are
restored with restoreGlobals(). Thus throw an exception whenever the
test case object is descruted but globals have not been restored, that
will prevent unintentional leaks.

Test runs for cirrusTest goes from 7s to 3s.

Later on WgConfTestCase can be extended to load a $wgConf object. That
seems to be a common behavior of loggingTest and cirrusTest.

Change-Id: I7a86e856881da69431c29b81cf1005070e029a0b