wiki.techinc.nl/tests/phpunit
Tim Starling 673d496f2d Have Database::addQuotes() pass through bare integers without quoting
Quotes started being added to integers in r4984 (August 2004). Before
that, is_numeric() was used to determine whether to add quotes, so
quotes were omitted from numeric strings, which is obviously wrong.

The idea here is to use the type of the variable to hint to the database
as to whether quotes are needed. The results are somewhat inconsistent,
since some callers do not convert numeric strings obtained from user
input to integers. That makes it a more conservative change. Callers can
opt out of unquoted integers by casting them to string.

The reason for doing this is that quoting integers turns out to be not
as harmless as originally assumed. We found a case of it confusing the
MariaDB query planner, causing inappropriate indexes to be used.

I also made addQuotes() consistently return a string, instead of
returning an integer for boolean values. This was already the case for
MySQL, but it seems like a good idea everywhere.

Bug: T238378
Change-Id: I70473280f542ee5ecd79e187f580807410fbd548
2019-11-18 11:40:28 +11:00
..
data Remove traling double newlines from text files 2019-10-23 21:17:43 +02:00
docs Add @coversNothing for left over tests and enable sniff 2019-02-02 21:53:40 -08:00
documentation tests: Use a fancy generator provider in ReleaseNotesTest 2019-07-02 19:49:43 +01:00
includes Have Database::addQuotes() pass through bare integers without quoting 2019-11-18 11:40:28 +11:00
integration/includes profiler: Remove ProfilerOutputDb and profileinfo.php entry point 2019-11-06 15:28:00 -05:00
languages Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
maintenance More backwards compatible changes for PHPUnit 2019-11-12 17:07:23 -08:00
mocks Add public as visibility in tests folder 2019-10-10 21:55:37 +02:00
skins tests: Add explicit return type void to setUp() and tearDown() 2019-10-30 14:31:22 -07:00
structure tests: Add explicit return type void to setUp() and tearDown() 2019-10-30 14:31:22 -07:00
suites tests: Add explicit return type void to setUp() and tearDown() 2019-10-30 14:31:22 -07:00
tests Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
unit More backwards compatible changes for PHPUnit 2019-11-12 17:07:23 -08:00
bootstrap.maintenance.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
bootstrap.php phpunit: Repair GLOBALS reset in MediaWikiUnitTestCase 2019-09-02 20:58:34 +01:00
HamcrestPHPUnitIntegration.php Use splat operator in HamcrestPHPUnitIntegration 2019-02-26 18:52:03 -08:00
LessFileCompilationTest.php Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
Makefile docs: Remove 'code-coverage' placeholder directory 2019-01-25 18:35:46 -08:00
MediaWikiCoversValidator.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiGroupValidator.php Move trivially compatible tests to the unit tests suite 2019-06-30 15:23:53 +02:00
MediaWikiIntegrationTestCase.php Remove PHPUnit4And6Compat from Test classes 2019-11-10 14:08:09 +01:00
MediaWikiLangTestCase.php tests: Add explicit return type void to setUp() and tearDown() 2019-10-30 14:31:22 -07:00
MediaWikiLoggerPHPUnitTestListener.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiPHPUnitCommand.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiPHPUnitResultPrinter.php Backwards-compatible PHPUnit 8 preparations 2019-11-02 12:40:07 -07:00
MediaWikiPHPUnitTestListener.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiTestCaseTrait.php Hard-deprecate LockManagerGroup::getDefault/getAny 2019-10-29 14:48:44 +02:00
MediaWikiTestResult.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiTestRunner.php Update tests to use PHPUnit 6 class names 2019-10-06 01:01:28 -07:00
MediaWikiUnitTestCase.php Remove PHPUnit4And6Compat from Test classes 2019-11-10 14:08:09 +01:00
phpunit.php tests: Nuke everything HHVM-related 2019-10-05 12:51:07 -07:00
PHPUnit4And6Compat.php PHPUnit4And6Compat tweaks 2019-10-04 19:28:38 -07:00
README Tests: Remove old TODO file and update README with integration notes 2019-07-17 13:00:54 -04:00
ResourceLoaderTestCase.php tests: Add explicit return type void to setUp() and tearDown() 2019-10-30 14:31:22 -07:00
run-tests.bat
suite.xml Define unit and integration test suites 2019-06-28 12:18:18 -04: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