There has long been a hack for previewing edits to user JS/CSS, where OutputPage would pass an 'excludepage' parameter to ResourceLoaderUserModule to tell it not to load one particular page and would instead embed that page statically. That's nice, but there are other places where we could use the same thing. This patch generalizes it: * DerivativeResourceLoaderContext may now contain a callback for mapping titles to replacement Content objects. * ResourceLoaderWikiModule::getContent() uses the overrides, and requests embedding when they're used. All subclasses in Gerrit should pick it up automatically. * OutputPage gains methods for callers to add to the override mapping, which it passes on to RL. It loses a bunch of the special casing it had for the 'user' and 'user.styles' modules. * EditPage sets the overrides on OutputPage when doing the preview, as does ApiParse for prop=headhtml. TemplateSandbox does too in I83fa0856. * OutputPage::userCanPreview() gets less specific to editing user CSS and JS, since RL now handles the embedding based on the actual modules' dependencies and EditPage only requests it on preview. ApiParse also gets a new hook to support TemplateSandbox's API integration (used in I83fa0856). Bug: T112474 Change-Id: Ib9d2ce42931c1de8372e231314a1f672d7e2ac0e |
||
|---|---|---|
| .. | ||
| data | ||
| docs | ||
| includes | ||
| languages | ||
| maintenance | ||
| mocks | ||
| skins | ||
| structure | ||
| suites | ||
| tests | ||
| autoload.ide.php | ||
| bootstrap.php | ||
| HamcrestPHPUnitIntegration.php | ||
| LessFileCompilationTest.php | ||
| Makefile | ||
| MediaWikiCoversValidator.php | ||
| MediaWikiLangTestCase.php | ||
| MediaWikiPHPUnitTestListener.php | ||
| MediaWikiTestCase.php | ||
| phpunit.php | ||
| PHPUnit4And6Compat.php | ||
| README | ||
| ResourceLoaderTestCase.php | ||
| run-tests.bat | ||
| suite.xml | ||
| TODO | ||
== MediaWiki PHPUnit Tests == The unit tests for MediaWiki are implemented using the PHPUnit testing framework and require PHPUnit to run. === WARNING === Some of the unit tests are DESTRUCTIVE and WILL ALTER YOUR WIKI'S CONTENTS. DO NOT RUN THESE TESTS ON A PRODUCTION SYSTEM OR ON ANY SYSTEM WHERE YOU NEED TO RETAIN YOUR DATA. == Installation == If you used composer to install MediaWiki's dependencies PHPUnit will already be available, unless you explicitly specified the --no-dev flag during the install. In this case just run "composer update". Otherwise follow the installation instructions in the PHPUnit Manual at: https://phpunit.de/manual/current/en/installation.html == Running tests == The tests are run from your operating system's command line. Ensure that you are in the tests/phpunit directory of your MediaWiki installation. On Unix-like operating systems, the tests runs are controlled with a makefile. Run command: make help for a full list of options for running tests. On Windows-family operating systems, run the 'run-tests.bat' batch file. === Writing tests === A guide to writing PHP unit tests for MediaWiki can be found at: https://www.mediawiki.org/wiki/Manual:PHP_unit_testing