aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/MessageTest.php
Commit message (Collapse)AuthorAgeFilesLines
* tests: Move test cases from /includes/ into sub folderUmherirrender2023-09-131-831/+0
| | | | | | | Follow move of the tested class Most moves are part of T321882 Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
* MWTimestamp,Message: Widen `@covers` annotations in unit testsTimo Tijhof2023-06-031-126/+5
| | | | | | | | | | | | | | | | | | | | | | Follows-up I6d845bdfbb80, I69b5385868, I4c7d826c7e, I1287f3979ab, which widened the `@covers` annotations of other test suites: > We lose useful coverage and spend valuable time keeping these tags > accurate through refactors (or worse, forget to do so). > > I've audited each test to confirm it is a general test of the > subject class, where tagging missing methods would be an accepted > change, thus widening it is merely a no-op that clarifies intent > and reduces maintenance. I am not disabling the "only track coverage > of specified subject" mechanism, nor am I claiming coverage in > in classes outside the subject under test. > > Tracking this narrow detail wastes time to keep methods in sync during > refactors, time to realize (and fix) when other people inevitably > dodn't keep them in sync, time lost in finding uncovered code to > write tests for only to realize it is already covered but not tagged. Change-Id: I7555c9b6b5100e861694dada45e691fd306b72be
* phpunit: Update `@covers` annotations for namespaced classesFunc2023-05-271-2/+2
| | | | | | | | | | | | We renamed many classes to be namespaced, but the `@covers` and `@coversDefaultClass` annotations weren't updated properly. PHPUnit didn't support short cover annotations with `use` statements, these didn't trigger any errors yet, because they are class alias. This patch is populated by a modified version of PhpunitAnnotationsSniff. Change-Id: I6c602290a30099239b17d2dc0d67b1488b4eaeeb
* build: Updating mediawiki/mediawiki-codesniffer to 41.0.0libraryupgrader2023-03-111-8/+8
| | | | | | | The following sniffs are failing and were disabled: * MediaWiki.Usage.ForbiddenFunctions.eval Change-Id: I6fd0a9296c88a77c3abec6e5e8d568bb469c2d6e
* Reorg: Move RawMessage to under language/Amir Sarabadani2022-12-161-0/+1
| | | | | | | | | | To follow Message. This is approved as part of RFC T166010. Also namespace it but doing it properly with PSR-4 would require namespacing every class under language/ and that will take some time. Bug: T321882 Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
* Fix casing of class and function name usagesReedy2022-12-041-1/+1
| | | | | Bug: T253628 Change-Id: I5c64f436d3cf757390b751ce3e34bfc7872bc176
* Message: Improve parameter type errorsBartosz Dziewoński2022-12-011-1/+2
| | | | | | …and avoid the use of MWException. Change-Id: Id07e301c3f20afa135e5469ee234a27354485652
* Partial Revert "Remove pre PHP 7.4 serialize()/unserialize()"Reedy2022-11-211-2/+2
| | | | | | | | | This reverts commit 27ee63f8c9d97ecc04cee0d7a29deca74b7bea5c. Reason for revert: Serialized Messages are stored in the database Bug: T323236 Change-Id: Ia8089201eedf3c0585bb7e970b3776a7e0882019
* Remove pre PHP 7.4 serialize()/unserialize()Reedy2022-11-101-2/+2
| | | | | Depends-On: I3b893152ed278a72b5e74ccf91a3381f319bfcd9 Change-Id: I9f69a9316eaec23103262ec2ffd5b85baaf16f3f
* tests: Use `overrideConfigValue(s)` where necessaryDerick Alangi2022-07-161-10/+7
| | | | | | | The files in `tests/phpunit/includes/` directory are now all covered. Will do sub-directories of `/includes/` next. Change-Id: I8d5655ce267b6d32cf3c7ee40dc5d2992631b5a6
* Only apply transformations for &uselang=qqx when actually using itBartosz Dziewoński2022-03-081-7/+0
| | | | | | | | Depends-On: I4f3b01eccf571475f1248db838a8aa6cba18b93e Depends-On: I0a0681b332abb623fc6871ab78da9e64a79fad84 Bug: T300069 Bug: T302469 Change-Id: I45f58034117e9041fe5403dbfcf83ba25f20518d
* Re-apply "Show message fallback keys when using &uselang=qqx"Bartosz Dziewoński2022-03-081-0/+23
| | | | | | | | | | | | | | | This affects messages created using wfMessageFallback() and related functions, in particular many messages used for navigation tabs in skins. Previous attempt in 11d7d97768fa384102eba4a530a535454ea4aa11, reverted in c83b530f952286f10c5d9a5bf7960bb6acf7be18 due to T302469. This attempt doesn't introduce any new placeholders to avoid that issue. Bug: T300069 Change-Id: Ib0e282b3864caf345e42dd7af4a529f43ae7ba67
* Revert "Show message fallback keys when using &uselang=qqx"Elliott Eggleston2022-02-231-23/+0
| | | | | | | | | This reverts commit 11d7d97768fa384102eba4a530a535454ea4aa11. Breaking fundraising banners with regexes in them. Bug: T302469 Change-Id: I0146a6a2907ca72792375e97a5b5392c6465614f
* Show message fallback keys when using &uselang=qqxBartosz Dziewoński2022-02-171-0/+23
| | | | | | | | | This affects messages created using wfMessageFallback() and related functions, in particular many messages used for navigation tabs in skins. Bug: T300069 Change-Id: Ia8ba35419285cfa77197810ae9df99e522a0f4ba
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-15/+15
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Remove or replace usages of "sanity"Reedy2021-11-211-2/+2
| | | | | Bug: T254646 Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
* Add Message/MessageValue user group member parameter typeTChin2021-11-161-0/+19
| | | | | | | * Added ParamType::OBJECT, which allows Stringable objects to be passed into MessageValue Bug: T278482 Change-Id: Ib4990f87d4ad70b7525d7aa05c8b97e90c121674
* Add message parameter type for User GroupsTChin2021-10-141-0/+15
| | | | | Bug: T278482 Change-Id: I45da5f73f8920b79b57c02776a05d0268d3480f2
* Message: Remove deprecated format propertyGergő Tisza2021-09-031-9/+0
| | | | | | | | | Remove Message::$format and the $format parameter of Message::toString(), soft-deprecated in 1.26 and hard-deprecated in 1.36. Also make the signature of toString() stricter. Bug: T146416 Change-Id: I19aa3e482968dea5164afb93b04a55f27c644ce6
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Use Message::page instead of Message::titlePetr Pchelko2021-06-091-1/+2
| | | | | | | Also modified new APIs added to ApiErrorFormatter to use PageReference instead of Title. Change-Id: I093c89f8e1e6d383603f887358be6ece70f23a02
* Replace Title in Message/MessageCachePetr Pchelko2021-06-091-3/+4
| | | | Change-Id: Ib0e36d767788edcdd8fa9ebc5de6bbde4cf50f12
* Remove meaningless ->expects( $this->any() ) from all testsThiemo Kreuz2021-04-231-3/+3
| | | | | | | | | | | | | | | It is not entirely meaningless. It might be an indicator that the number of calls to a method is intentionally unlimited. This is similar to e.g. an @inheritDoc PHPDoc comment that marks a method as being "intentionally undocumented". However, what's the meaning of being "intentionally unconstrained"? Let's just not have any constraint then. I feel all these ->expects( $this->any() ) bloat the test code so much that it's never worth it. Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
* Merge "Replace PHPUnit ->returnValue() with ->willReturn() shortcut"jenkins-bot2021-04-221-4/+2
|\
| * Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-221-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | It's the same and makes the test code much more readable, I would like to argue. Because of the was I split all the changes I made into smaller patches this patch contains some other changes in the same lines where I could not split them off. E.g. removal of ->any(), which is the default anyway and doesn't do anything. Change-Id: Ib297b989d4aec33b31a4e33fe9d5032865b39be0
* | Message: Deprecate toString() with an implicit formatTimo Tijhof2021-04-221-5/+15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* phpunit: Mass-replace setMethods with onlyMethods and adjustDaimona Eaytoy2021-04-161-1/+1
| | | | | | | | | | | | Ended up using grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g' special-casing setMethods( null ) -> onlyMethods( [] ) and then manual fix of failing test (from PS2 onwards). Bug: T278010 Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
* Add Message/MessageValue datetime parameter typesPetr Pchelko2021-03-301-0/+52
| | | | | | | | | | | This is used quite a lot in the codebase and it's a reason for a lot of usages of $wgLang. Time and date seems generic enough to put into Message library - we already have references to Wikimedia\Timestamp library there. Bug: T278482 Change-Id: If7cb5f5dcfa736b6530f731af9dc3af168812054
* tests: Use ::class on exception namesUmherirrender2021-01-031-3/+3
| | | | Change-Id: Iadc2eabb7d132a21cffccf5468b92328a64acb4a
* Replace all call_user_func(_array) in all testsThiemo Kreuz2020-06-061-1/+1
| | | | | | | | | | | | | There is native support for all of this now in PHP, thanks to changes and additions that have been made in later versions. There should be no need any more to ever use call_user_func() or call_user_func_array(). Reviewing this should be fairly easy: Because this patch touches exclusivly tests, but no production code, there is no such thing as "insufficent test coverage". As long as CI goes green, this should be fine. Change-Id: Ib9690103687734bb5a85d3dab0e5642a07087bbc
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Merge "Remove Language::factory and getParentLanguage use"jenkins-bot2019-10-291-21/+20
|\
| * Remove Language::factory and getParentLanguage useAryeh Gregor2019-10-271-21/+20
| | | | | | | | Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
* | Try fixing flaky testBrad Jorsch2019-10-231-2/+3
|/ | | | | | | | | | This test has been said to be flaky, and I suppose it could be if it somehow regularly manages to tick a second in between the two calls to wfTimestampNow(). So let's make just one call and reuse the value to see if that fixes it. Bug: T232266 Change-Id: I8fbdfa2f906839423cc238cd3741b94435a84505
* phpcs: Enable ↵James D. Forrester2019-10-141-1/+1
| | | | | | MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException* and make pass Change-Id: I63f97497714a32236268be6965c5e181dade6c58
* Kill the remaining usages of PHPUnit4And6Compat methodsDaimona Eaytoy2019-10-061-1/+1
| | | | | Bug: T192167 Change-Id: I1ea19e9b53683b7d32ff9836990ee73ab3e11104
* Remove unneeded overrideMwServices/resetServicesAryeh Gregor2019-08-291-3/+0
| | | | Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
* Convert MessageCache to serviceAryeh Gregor2019-08-181-1/+0
| | | | | | Depends-On: Ia70e6c75f6e8a533f20cd44ebb05e013678e9951 Depends-On: I546eda0377f3a50843144b1450d3fbe8e4e02a8a Change-Id: I305539a8598535a73e5cd280b2becdafa740ef97
* Remove all $wgParser use from coreAryeh Gregor2019-04-171-3/+1
| | | | | | Bug: T160811 Change-Id: I0556c04d33386d0339e02e2bf7a1ee74d97c2abd
* Add some missing @covers tagsKunal Mehta2019-02-021-0/+3
| | | | Change-Id: Idb9af9515702ee9748755d7799663713b2283647
* Use ParserFactory in a bunch of placesAryeh Gregor2018-08-111-4/+2
| | | | | | | | I wasn't sure how to convert the rest of the occurrences in core (there are a significant number). Bug: T200881 Change-Id: I114bba946cd3ea8a293121e275588c3c4d174f94
* Automatically reset namespace caches when neededAryeh Gregor2018-08-011-2/+2
| | | | | | | | | | | | This avoids error-prone code written separately in every test. In addition to no existing tests resetting the TitleFormatter (more services probably need to be reset as well), they mostly reset only the namespace cache on $wgContLang, which wouldn't help for any other language. The parser test runner still doesn't do this, but maybe it should. Change-Id: I44b7a1aec48f14b0950907fa14bd0df80f674296
* Use wikimedia/object-factory 1.0.0Kunal Mehta2018-02-041-0/+1
| | | | | | | | Deprecate the unnamespaced version and move it to includes/compat. Bug: T147167 Depends-On: I39c805bfb98b32f32f3d0dc1eee9e823afe1c21a Change-Id: I3780c7adf51683f3f7adb35a88f9a25a0a2e2530
* Use ::class to resolve class names in testsUmherirrender2018-01-261-6/+6
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* Remove method level @group Database tagsaddshore2017-11-231-1/+3
| | | | | | | MessageTest did not have the group at class level either so that is added in this patch. Change-Id: Idb6213282d6854044f374c9df51ea32d0a5523e1
* Switch to librarized version of TestingAccessWrapperGergő Tisza2017-04-201-1/+2
| | | | | | | | | | | | | | | Replaces \TestingAccessWrapper (defined in core) with \Wikimedia\TestingAccessWrapper (defined in the composer package wikimedia/testing-access-wrapper). See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper for downstream patches. The core version of the class is kept around for a while to avoid circular dependency problems. Bug: T163434 Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
* SECURITY: Disable <html> tag on system messages despite $wgRawHtml = true;Brian Wolff2017-03-281-0/+17
| | | | | | | | | | System messages may take parameters from untrusted sources. This may include taking parameters from urls given by unauthenticated users even if the wiki is a read-only wiki. Allowing <html> tags in such a context seems like an accident waiting to happen. Bug: T156184 Change-Id: I661f482986d319cf41da1d3e7b20a0f028a42e90
* Miscellaneous indentation tweaksBartosz Dziewoński2017-02-271-2/+2
| | | | | | | | | | I was bored. What? Don't look at me that way. I mostly targetted mixed tabs and spaces, but others were not spared. Note that some of the whitespace changes are inside HTML output, extended regexps or SQL snippets. Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
* tests: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-211-1/+1
| | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
* wfMessage: use Message::params() to handle all the message parametersZhuyifei19992016-12-201-0/+29
| | | | | | | | | | | | | | The old code was similar to Message::params(), but Message::params() was unable to handle "special" parameters and received an overhaul in 7f2663f, yet wfMessage remained broken. To avoid duplication, wfMessage shall call Message::params() to correctly handle these parameters. CategoryMembershipChange::getChangeMessageText and its caller has been updated so as not to take advantage of this bug. Bug: T153747 Change-Id: I6667acf7e71c9db07fefc9fbb741c160e15823ff