wiki.techinc.nl/tests/phpunit/includes/parser
Timo Tijhof 29e0183a56 phpunit: Repair GLOBALS reset in MediaWikiUnitTestCase
This code didn't work because the $GLOBALS array is exposed by reference.
Once this reference was broken by unset(), the rest just manipulated a
local array that happens to be called "GLOBALS". It must not be unset or
re-assigned. It can only be changed in-place.

Before this, the execution of a MediaWikiUnitTestCase test stored a
copy of GLOBALS in unitGlobals, then lost the GLOBALS pointer and
created a new variable called "GLOBALS". As such, the tearDown() function
didn't do what it meant to do, either – which then results in odd
failures like T230023

Rewrite it as follows:

* In setup, store the current GLOBALS keys and values, then reduce
  GLOBALS to only the whitelisted keys and values.

* In teardown, restore the original state.

* As optimisation, do this from setUpBeforeClass as well, so that
  there are relatively few globals to reset between tests.
  (Thanks @Simetrical!)

The following tests were previously passing by accident under
MediaWikiUnitTestCase but actually did depend on global config.

* MainSlotRoleHandlerTest (…, ContentHandler, $wgContentHandlers)
* SlotRecordTest (…, ContentHandler, $wgContentHandlers)
* WikiReferenceTest (wfParseUrl, $wgUrlProtocols)
* DifferenceEngineSlotDiffRendererTest (DifferenceEngine, wfDebug, …)
* SlotDiffRendererTest (…, ContentHandler, $wgContentHandlers)
* FileBackendDBRepoWrapperTest (wfWikiID, "Backend domain ID not provided")
* JpegMetadataExtractorTest (…, wfDebug, …, LoggerFactory, …)
* ParserFactoryTest (…, wfDebug, …, LoggerFactory, InvalidArgumentException)
* MediaWikiPageNameNormalizerTest (…, wfDebug, …, LoggerFactory, …)
* SiteExporterTest (SiteImporter, wfLogWarning, …)
* SiteImporterTest (Site::newForType, $wgSiteTypes)
* ZipDirectoryReaderTest (…, wfDebug, …, LoggerFactory, …)

Bug: T230023
Change-Id: Ic22075bb5e81b7c2c4c1b8647547aa55306a10a7
2019-09-02 20:58:34 +01:00
..
CoreParserFunctionsTest.php Ensure canHaveTalkPage returns false when getTalkPage would fail. 2019-07-03 10:40:10 +02:00
MagicVariableTest.php Use setContentLang() instead of setMwGlobals() 2018-07-26 11:35:58 +00:00
ParserFactoryIntegrationTest.php Introduce MovePageFactory 2019-08-19 20:25:31 +03:00
ParserFactoryTest.php phpunit: Repair GLOBALS reset in MediaWikiUnitTestCase 2019-09-02 20:58:34 +01:00
ParserMethodsTest.php parser: document what 0/null rev IDs do when given to Parser::parse 2019-08-21 11:13:49 -07:00
ParserOptionsTest.php Avoid extra parse/save delay for users with non-canonical parser options 2019-04-14 02:00:16 +00:00
ParserOutputTest.php Revert rename of mSpeculativeRevId to speculativeRevIdUsed 2019-07-31 02:42:27 +00:00
ParserPreloadTest.php Revert "Separate MediaWiki unit and integration tests" 2019-06-13 23:00:08 +00:00
ParserTest.php Don't pass Config to Parser(Factory) 2019-05-20 11:19:21 -05:00
PreprocessorTest.php Hard deprecate Preprocessor_DOM 2019-06-14 12:21:40 -04:00
SanitizerTest.php Unset all globals unneeded for unit tests, assert correct directory 2019-07-09 14:09:29 -04:00
StripStateTest.php StripState testing and cleanup 2018-03-05 16:43:58 +11:00
TagHooksTest.php Mass conversion of $wgContLang to service 2018-08-11 22:44:29 -06:00