* Injecting the cache object makes the class easier to test. * The $forceRecompile parameter was not used anywhere, not tested, and only mentioned in one README (fixed in I13fba7314). Based on past experience I generally expect that when bypassing a cache, it is neither read from nor written to. Such feature might be reached out to when testing something, in which case it should not be stored. If this was intended as a way to purge it in prod via eval.php, we generally don't provide dedicated purging commands in code. We either call BagOStuff or Memc/Apcu directly, or invalidate the underlying data (e.g. touch the template file, or bump the cache version). To use TemplateParser without caching, one can still pass 'new EmptyBagOStuff' instead if needed. * Set the $ttl parameter in the set() call. It is generally an anti-pattern to store something without any TTL as that means it can needlessly compete for space even after further deployments have changed the key or stopped using a particular key. For now I used a liberal default of 1 week. Change-Id: Ic84b996b46c72e9dc33eed2645204fc2d6c5240c |
||
|---|---|---|
| .. | ||
| data | ||
| docs | ||
| documentation | ||
| includes | ||
| integration/includes | ||
| languages | ||
| maintenance | ||
| mocks | ||
| skins | ||
| structure | ||
| suites | ||
| tests | ||
| unit | ||
| bootstrap.maintenance.php | ||
| bootstrap.php | ||
| HamcrestPHPUnitIntegration.php | ||
| LessFileCompilationTest.php | ||
| Makefile | ||
| MediaWikiCliOptions.php | ||
| MediaWikiCoversValidator.php | ||
| MediaWikiGroupValidator.php | ||
| MediaWikiIntegrationTestCase.php | ||
| MediaWikiLangTestCase.php | ||
| MediaWikiLoggerPHPUnitTestListener.php | ||
| MediaWikiPHPUnitCommand.php | ||
| MediaWikiPHPUnitResultPrinter.php | ||
| MediaWikiPHPUnitTestListener.php | ||
| MediaWikiTestCaseTrait.php | ||
| MediaWikiUnitTestCase.php | ||
| phpunit.php | ||
| PHPUnit4And6Compat.php | ||
| PHPUnit6And8Compat.php | ||
| README | ||
| ResourceLoaderTestCase.php | ||
| run-tests.bat | ||
| suite.xml | ||
== MediaWiki PHPUnit Tests == The unit and integration tests for MediaWiki are implemented using the PHPUnit testing framework and require PHPUnit to run. === WARNING === Some of the integration 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