wiki.techinc.nl/tests/phpunit
Timo Tijhof 3fdfef96e4 context: Add a cached RequestContext::getActionName method
This method is dependent on, and inherently must depend on, all of
Title, WikiPage, and WebRequest. And, like Title and WikiPage,
which also have getters in RequestContext, Action is also derived
from a query parameter that is widely recognised in almost all
web requests to index.php.

The status quo in core and extensions, is to obtain this value
via Action::getActionName(), which as a static method that bypasses
dependency injection and also has the problem of not being cached.
Caching it within ActionFactory seems hard and awkward, due to
varying by context.

In change I61d66211bd (22f9a32853) a cached wrapper method was added
internally to the Skin class. In change I8cbc4bba4d248d9 (235820d631)
another cached wrapper was added in the Gadgets extension.

This change takes this approach further by making it a stable public
method on RequestContext.

To facilitate testing and to offer basic confidence in this working
correctly, this commit also adopts the new method in two place that
are considered "safe" (Skin, and OutputPage). Both of these are
called relatively late in the PHP proccess and well after any Setup
code and overrides (such as in MediaWiki.php), during which it is
more complex to call this. I'll audit and update those in a subsequent
change.

Change-Id: I1e259b54dca48a32be5a8c6cbb8eb69aec2da115
2022-03-25 12:12:48 +00:00
..
data Bump minimum required version for upgrade to 1.31 2022-03-15 22:12:59 +01:00
docs
includes context: Add a cached RequestContext::getActionName method 2022-03-25 12:12:48 +00:00
integration/includes Fix core newtalk 304 suppression and update deferral 2022-03-18 16:52:12 +11:00
languages Language: retrieve MainConfig instead of using a bunch of globals 2022-03-15 02:58:42 +00:00
maintenance Benchmark: Force string representation of arguments 2022-03-11 23:14:36 +00:00
mocks Set page id to 0 for pages in virtual namespaces 2022-03-10 20:12:27 +00:00
structure phpunit: Revert "testConfigGeneration" structure test to simpler version 2022-03-24 14:57:47 +00:00
suites SuiteEventsTrait: don't call setUp() for an empty suite 2022-03-17 14:47:21 +11:00
tests Revert "tests: Add @group Broken to 2022-03-17 23:02:55 +00:00
unit rdbms: rename wasKnownStatementRollbackError() to isKnownStatementRollbackError() 2022-03-22 22:59:09 +00:00
bootstrap.maintenance.php
bootstrap.php Define MW_INSTALL_PATH constant and BaseDirectory config. 2022-03-04 14:18:27 +01:00
HamcrestPHPUnitIntegration.php
LessFileCompilationTest.php
Makefile
MediaWikiCliOptions.php Improve ObjectCache integration tests 2022-02-11 10:20:33 +11:00
MediaWikiCoversValidator.php
MediaWikiGroupValidator.php
MediaWikiIntegrationTestCase.php Revert "phpunit: Set $wgSQLMode from DevelopmentSettings instead of MediaWikiIntegrationTestCase" 2022-03-24 16:55:02 +00:00
MediaWikiLangTestCase.php
MediaWikiLoggerPHPUnitExtension.php
MediaWikiPHPUnitCommand.php
MediaWikiPHPUnitResultPrinter.php
MediaWikiTestCaseTrait.php Add convenience methods for asserting status. 2022-03-16 22:44:25 +01:00
MediaWikiUnitTestCase.php Use updated ObjectFactory namespace 2022-03-09 23:04:51 +00:00
phpunit.php tests: Change use of AtEase to at operator 2022-02-24 21:29:51 +00:00
README
ResourceLoaderTestCase.php Define MW_INSTALL_PATH constant and BaseDirectory config. 2022-03-04 14:18:27 +01:00
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