wiki.techinc.nl/tests/phpunit
Daimona Eaytoy 090599c048 Simplify timezone-related code for user preferences
This patch simplifies and fixes a few issues in code related to the
'timecorrection' user setting:
- Always re-apply UserTimeCorrection normalization to the preference
  value, although it should be already normalized
- Avoid duplicating code from UserTimeCorrection, both for the
  pipe-splitting and the offset computation/fallback
- Use better variable names
- Inject an ITextFormatter for generating the dropdown options, instead
  of a ContextSource (ew) or a Language, removing calls to wfMessage as
  well. Note that the ITextFormatter is not injected into the
  preferences factory because the eventual goal is to move the code to a
  new HTMLFormField class.
- In TimezoneFilter, remove a redundant check: the value comes from the
  form, and the option for using the system time is always "System|XXX",
  never just "System". This seems to have been introduced in
  I2cadac00e46dff2bc7d81ac2f294ea2ae4e72f47; the previous code was only
  comparing $data[0], and not $tz. Change the test accordingly and add a
  test case.
- Add missing star to docblocks in UserTimeCorrection, as well as a
  missing int cast.
- Fix typo and other style issues in UserTimeCorrectionTest
- Bonus: add missing docblock star in HTMLApiField

Bug: T309629
Change-Id: Iab35eb17259826429e4b6bc1ba7385ab57884e98
2022-09-12 12:23:48 +00:00
..
data Add 1.39 snapshot to sqlite db tests 2022-09-06 18:32:46 +00:00
docs
includes Merge "Add cancreateaccount property to userinfo API" 2022-09-12 06:54:26 +00:00
integration/includes Merge "parser: Use a <meta> tag for the internal TOC_PLACEHOLDER" 2022-09-09 21:12:34 +00:00
languages Update Language::isWellFormedLanguageTag 2022-08-30 10:54:18 +00:00
maintenance tests: Replace deprecated WikiPage::factory 2022-09-02 19:34:02 +00:00
mocks Use native array_column() in tests instead of loops 2022-08-16 15:41:14 +02:00
structure ResourceLoader: Add structure test to detect incompatible requiresES6 2022-08-31 18:13:52 +00:00
suites Followup on 02d13afa: Unbreak Parsoid parser test runs 2022-08-25 17:32:24 -05:00
tests rdbms: add getDomainChangeException() call to DBConnRef::tablePrefix() 2022-08-03 21:41:09 +00:00
unit Simplify timezone-related code for user preferences 2022-09-12 12:23:48 +00:00
bootstrap.maintenance.php
bootstrap.php
HamcrestPHPUnitIntegration.php
LessFileCompilationTest.php
MediaWikiCliOptions.php
MediaWikiCoversValidator.php
MediaWikiGroupValidator.php
MediaWikiIntegrationTestCase.php Merge "tests: Replace deprecated WikiPage::factory" 2022-09-09 16:25:08 +00:00
MediaWikiLangTestCase.php
MediaWikiLoggerPHPUnitExtension.php phpunit: Fix trivial dynamic property usages in tests 2022-07-29 01:59:23 +02:00
MediaWikiPHPUnitResultPrinter.php
MediaWikiTestCaseTrait.php
MediaWikiUnitTestCase.php Migrate use of ${var}-style string interpolation 2022-07-29 02:45:09 +02:00
MWTestDox.php
phpunit.php
README.md
ResourceLoaderTestCase.php tests: Migrate away from setMwGlobals() 2022-08-22 20:17:49 +00:00
suite.xml

MediaWiki PHPUnit tests

WARNING: Integration tests may be destructive and alter or remove parts of your local database. We try to use temporary tables where possible, but you must never run tests on a production server or on a wiki where you don't want to lose data.

Running tests

If you haven't already, run composer update (specifically without --no-dev) in the MediaWiki core directory. This will install PHPUnit.

To read about how to run specific tests, refer to:

https://www.mediawiki.org/wiki/Manual:PHP_unit_testing/Running_the_tests

Writing tests

A guide to writing PHPUnit tests for MediaWiki can be found at:

https://www.mediawiki.org/wiki/Manual:PHP_unit_testing