wiki.techinc.nl/tests/phpunit
Timo Tijhof e4b7341fb6 TemplateParser: Inject BagOStuff and deprecate '$forceRecompile'
* 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
2020-03-23 20:09:05 +00:00
..
data languages: Move default $wgNamespaceAliases to MessagesEn.php 2020-03-14 19:27:40 +00:00
docs
documentation Update all use of $wgVersion to MW_VERSION 2020-02-25 02:16:12 +00:00
includes Make MWException show up pretty even if $wgLang is a stub 2020-03-23 03:49:45 +00:00
integration/includes TemplateParser: Inject BagOStuff and deprecate '$forceRecompile' 2020-03-23 20:09:05 +00:00
languages Add MediaWikiIntegrationTestCase::assertArraySubmapSame() 2020-03-19 15:53:59 -07:00
maintenance Remove auto-generated and empty lines in comments 2020-03-17 09:55:24 +01:00
mocks Remove LanguageConverter dependencies on Title and use LinkTarget 2020-02-12 18:37:11 +03:00
skins Use MediaWikiServices::getMessageCache 2020-03-14 14:25:03 +01:00
structure Add PSR-4 mappings for existing namespaces and the top level 2020-03-10 21:08:30 +11:00
suites Remove Preprocessor_DOM, deprecated in 1.34 2020-01-25 11:22:45 -05:00
tests Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
unit page/update endpoint 2020-03-23 16:59:21 +01:00
bootstrap.maintenance.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
bootstrap.php Allow specifying autoloaded classes for tests 2019-12-10 21:39:30 +00:00
HamcrestPHPUnitIntegration.php Add missing @param and @return to documentation 2019-11-16 13:45:55 +01:00
LessFileCompilationTest.php resourceloader: Separate style processing from style file loading 2020-02-12 20:23:24 +00:00
Makefile
MediaWikiCliOptions.php Fix broken running tests locally in IDE 2019-11-21 16:28:12 +00:00
MediaWikiCoversValidator.php phpunit: Speed up MediaWikiCoversValidator trait 2020-03-08 18:51:38 +00:00
MediaWikiGroupValidator.php
MediaWikiIntegrationTestCase.php Add MediaWikiIntegrationTestCase::assertArraySubmapSame() 2020-03-19 15:53:59 -07:00
MediaWikiLangTestCase.php Use MediaWikiServices::getMessageCache 2020-03-14 14:25:03 +01:00
MediaWikiLoggerPHPUnitTestListener.php Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
MediaWikiPHPUnitCommand.php Show the PHPUnit help in phpunit.php --help 2019-11-25 17:19:20 +11:00
MediaWikiPHPUnitResultPrinter.php Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
MediaWikiPHPUnitTestListener.php Upgrade PHPUnit to version 7 2019-11-20 21:02:33 -08:00
MediaWikiTestCaseTrait.php SearchHandler: add unit test 2020-03-02 20:52:46 +01:00
MediaWikiUnitTestCase.php Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse 2020-01-10 09:32:25 -08:00
phpunit.php phpunit: fix parameter mangling 2020-01-23 18:02:53 +01:00
PHPUnit4And6Compat.php PHPUnit4And6Compat tweaks 2019-10-04 19:28:38 -07:00
PHPUnit6And8Compat.php phpunit: Remove 6And8Compat trait from base classes 2019-11-21 17:42:39 +00:00
README
ResourceLoaderTestCase.php Add missing @param and @return to documentation 2019-11-16 13:45:55 +01:00
run-tests.bat
suite.xml phpunit: Fix omission of 'integration/' in phpunit.php runner 2020-03-20 04:19:13 +00:00

== 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