wiki.techinc.nl/tests/phpunit
Timo Tijhof 73e718e373 Message: Deprecate toString() with an implicit format
This functionality exists to enable the anti-pattern of calling a
format method, without using its return value, and then subsequently
calling toString() to parse the same message, the same way, a second
time with the format you just called.

For example:

```
$msg = new Message('laggedreplicamode');

echo $msg->plain();
// <strong>Warning:</strong> Page may not contain recent
echo $msg->toString();
// <strong>Warning:</strong> Page may not contain recent

echo $msg->escaped();
// &lt;strong&gt;Warning:&lt;/strong&gt; Page may not contain recent
echo $msg->toString();
// &lt;strong&gt;Warning:&lt;/strong&gt; Page may not contain recent
```

Deprecate this rare anti-pattern in favour of using the return value
from the formatting methods such as $msg->plain() and $msg->escaped(),
or for compat we can also support $msg->toString('plain') etc.

This commit also fixes an unintentional lie in the assertion message
of one of the unit tests, which was claiming that toString() is
unaffected by format calls, when in fact it is. (And is what we are
deprecating here).

This implicit formatting and the related $this->format field will
be removed in 1.37.

Bug: T146416
Depends-On: Ia257621fb421854bf13e2965b04009663711ba0a
Change-Id: Ibb22099ff8042406e441d6c7fab87537d3ac92aa
2021-04-22 00:18:59 +00:00
..
data DoctrineSchemaBuilder: Do not add prefix placeholder for Postgres at all 2021-04-06 00:23:14 +00:00
docs
includes Message: Deprecate toString() with an implicit format 2021-04-22 00:18:59 +00:00
integration/includes Fix parameter order of setWatch to match add/removeWatch 2021-04-21 04:41:38 +00:00
languages phpunit: Mass-replace setMethods with onlyMethods and adjust 2021-04-16 20:15:00 +02:00
maintenance phpunit: Mass-replace setMethods with onlyMethods and adjust 2021-04-16 20:15:00 +02:00
mocks Remove Title from public interface of OutputPage 2021-04-16 10:01:56 -07:00
structure Remove $actor field from UsererIdentityValue 2021-04-13 18:18:06 +00:00
suites
tests
unit Use WatchlistManager in API classes 2021-04-21 04:41:06 +00:00
bootstrap.maintenance.php
bootstrap.php
HamcrestPHPUnitIntegration.php
LessFileCompilationTest.php
Makefile
MediaWikiCliOptions.php
MediaWikiCoversValidator.php
MediaWikiGroupValidator.php
MediaWikiHooksPHPUnitExtension.php phpunit: Remove MediaWikiPHPUnitTestListener 2021-03-20 15:55:26 +01:00
MediaWikiIntegrationTestCase.php Merge "Reset fake timestamps for unit tests too" 2021-04-14 21:45:02 +00:00
MediaWikiLangTestCase.php
MediaWikiLoggerPHPUnitExtension.php
MediaWikiPHPUnitCommand.php phpunit: Remove MediaWikiPHPUnitTestListener 2021-03-20 15:55:26 +01:00
MediaWikiPHPUnitResultPrinter.php
MediaWikiTestCaseTrait.php phpunit: Mass-replace setMethods with onlyMethods and adjust 2021-04-16 20:15:00 +02:00
MediaWikiUnitTestCase.php tests: Avoid problematic language in comments and internal code 2021-03-28 21:21:28 -07:00
phpunit.php Use ::class for class name 2021-04-08 21:17:42 +02:00
README
ResourceLoaderTestCase.php phpunit: Mass-replace setMethods with onlyMethods and adjust 2021-04-16 20:15:00 +02:00
run-tests.bat
suite.xml phpunit: Remove MediaWikiPHPUnitTestListener 2021-03-20 15:55:26 +01: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