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 |
||
|---|---|---|
| .. | ||
| data | ||
| docs | ||
| includes | ||
| integration/includes | ||
| languages | ||
| maintenance | ||
| mocks | ||
| structure | ||
| suites | ||
| tests | ||
| unit | ||
| bootstrap.maintenance.php | ||
| bootstrap.php | ||
| HamcrestPHPUnitIntegration.php | ||
| LessFileCompilationTest.php | ||
| MediaWikiCliOptions.php | ||
| MediaWikiCoversValidator.php | ||
| MediaWikiGroupValidator.php | ||
| MediaWikiIntegrationTestCase.php | ||
| MediaWikiLangTestCase.php | ||
| MediaWikiLoggerPHPUnitExtension.php | ||
| MediaWikiPHPUnitResultPrinter.php | ||
| MediaWikiTestCaseTrait.php | ||
| MediaWikiUnitTestCase.php | ||
| MWTestDox.php | ||
| phpunit.php | ||
| README.md | ||
| ResourceLoaderTestCase.php | ||
| 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: