aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/changes/OldChangesListTest.php
Commit message (Collapse)AuthorAgeFilesLines
* recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/Timo Tijhof2024-08-291-237/+0
| | | | | | | | | | | | | | | | It is part of the component at https://phabricator.wikimedia.org/tag/mediawiki-recent-changes/ and https://www.mediawiki.org/wiki/Developers/Maintainers and since Ifac20da51f7e809f under the same "Recent changes" doc group. The Maintainers list oddly enough lists only rcfeed and completely forgets the majority of it under /includes/changes (or now, /includes/recentchanges). Bug: T364652 Change-Id: I94e6705672c1e2821bdc726aa7a383d9e7c1f7b5
* phpunit: Fix tests relying on implicit wgScript/wgArticlePathTimo Tijhof2024-05-051-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A number of tests have hardcoded expections that pass only in WMF CI where Quibble has LocalSettings.php with $wgScript and $wgArticlePath set a certain way. We could fix these by adding setMwGlobals() in their tests, as we often do, but these are so often forgotten that I'd rather we just add them to TestSetup.php so that it is simply impossible to write a test that that passes locally for you (if you have the same config) but not for someone else. There is a larger project in there somewhere about expanding this slowly such that we basically only pluck DB-settings and extension enablement from LocalSettings and otherwise run the tests with the default settings in PHPUnit. Pretty much by definition, any (other) setting you have in LocalSettings is irrelevant because it either: 1. has no effect on the test (majority, harmless either way), 2. has a custom default via TestSetup.php (which has precedence over LocalSettings.php), 3. is relevant to the code being tested and the test case correctly calls setMwGlobals() to ensure a consistent value during test. 4. is relevant to the tested code but has no override, thus only passes if you happen to have the "right" value set for it (undesirable). Case 4 is already categorically impossible for the most common config settings that influence random code because we give them a value in TestSetup.php. This patch expands that to include $wgScript and $wgArticlePath. Perhaps in the future we can think about a way to do this automatically by either re-applying MainConfigSchema (sans db settings) or by only selectively applying LocalSettings.php in the first place. This patch follows-up I072ddf89562fe, which added a test case in WikitextContentHandlerIntegrationTest.php that assumed "/index.php" as the value of $wgScript. This passes in WMF CI since Quibble uses that value, but the tests failed in most local development installs since those tend to use "/w" instead. Rather than one-off fixing that one test with overrideConfigValues(), switch to a more general fixture, since the precise values don't matter for this test. Bug: T349087 Bug: T277470 Change-Id: If4304b7ca4a838bd892d4516a0b5c6dfbc30986e
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-1/+1
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace includes/contextJames D. Forrester2024-02-081-0/+1
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* tests: Make some PHPUnit data providers staticUmherirrender2023-05-201-1/+1
| | | | | | | | | Initally used a new sniff with autofix (T333745), but some provide are defined non-static in TestBase class and need more work to make them static in a compatible way Bug: T332865 Change-Id: I889d33424f0c01fb26f2d86f8d4fc3de3e568843
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* tests: Replace assertRegExp with assertMatchesRegularExpressionDaimona Eaytoy2022-10-071-15/+15
| | | | | | | | | | | | | | | | | | And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The methods were renamed in PHPUnit 9. Done automatically with: grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/" grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/" Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it remains smaller and easier to review. Also make a test use MediaWikiUnitTestCase (it's already in the unit/ dir) so that it can access the forward-compat method. Bug: T243600 Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
* tests: Migrate `setMwGlobals()` to `overrideConfigValue(s)()`Derick Alangi2022-07-231-3/+3
| | | | | | | | | | | | | | Directories covered are: - tests/phpunit/includes/cache/ - tests/phpunit/includes/changes/ - tests/phpunit/includes/changetags/ - tests/phpunit/includes/config/ - tests/phpunit/includes/content/ - tests/phpunit/includes/debug/ - tests/phpunit/includes/deferred/ - tests/phpunit/includes/diff/ Change-Id: I3a1f586867db7d57b177e13a03a4593f7eed09f4
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-07-061-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
* 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
* Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-221-1/+1
| | | | | | | | | | | | 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
* 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
* Remove constructors from test classesDannyS7122021-03-081-6/+1
| | | | | | | Tests should put their setup code in ::setUp(), rather than __construct Change-Id: I622f017f3c78a72acc65310f37d61dbec2a5da79
* Tests: Mark more more closures as staticUmherirrender2021-02-091-1/+1
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Add tests for Hook run call sitesNikki Nikkhoui2020-05-141-0/+10
| | | | | | | Add a few tests for hook run call sites to ensure hookrunner is executed and with the correct arguments. Change-Id: Icb90f1caca7c159f6f753e28e01b139e5c741500
* Stop using assertContains with string haystackDaimona Eaytoy2019-12-151-2/+2
| | | | | | | | This was done automatically by replacing every assertContains with string *needle*. Then verifying the results. Bug: T192167 Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-1/+1
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* i18n: Rename 11 messages for case-complianceJames D. Forrester2019-05-181-1/+1
| | | | | | | | | | | | | | | | | | | Can't yet enforce due to the API. * allmessagesnotsupportedDB * rcfilters-filtergroup-userExpLevel * rcfilters-filtergroup-lastRevision * number_of_watching_users_RCview * apihelp-query+allfileusages-example-B * apihelp-query+allimages-example-B * apihelp-query+alllinks-example-B * apihelp-query+allpages-example-B * apihelp-query+allredirects-example-B * apihelp-query+alltransclusions-example-B * apihelp-query+allusers-example-Y * apiwarn-wgDebugAPI Change-Id: I95961dfeb43e9cfadc867a48866af6335022572a
* Unwatch link for pages in Special:WatchlistGeoffrey Mon2017-08-121-0/+34
| | | | | | | | | | | | | | | | | | | When the 'watchlistunwatchlinks' preference option is enabled, this adds a '×' link to each entry of the watchlist that unwatches the page of that entry. When clicked, it changes into a '+' which can be used to re-watch the page (effectively undoing the earlier unwatch). When a page is unwatched, its entries and the entries of its associated talk page (or vice versa) become translucent and are struck through. Without JS, '×'/'+' link to action=(un)watch for the relevant page. In addition, ChangesList classes have been modified to allow a prefixer that adds a prefix to each line (used in this case to put the unwatch link) and to add HTML data attributes to reliably determine the target page of each entry. Unit tests have been updated accordingly. Bug: T2424 Change-Id: I450b2901413d7e75c11de2a446829fdbb22d31e1
* Make phpcs passUmherirrender2017-08-111-4/+8
| | | | | | | | Reenable MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace, because the mentioned bug is fixed Bug: T172933 Change-Id: I1593bdba2295ebed401b921f2beabed69dba7638
* RCFilters: show new changesStephane Bisson2017-07-311-2/+2
| | | | | | | | | | | When "live update" is off and new changes are detected, show a link to load and prepend the changes to the list. Also adding a line between old and new changes when grouping by pages is off. Bug: T163426 Change-Id: I6a111d23956bdc04caa4c71e9deede056779aafa
* ChangesList: Expose basic properties of lines as data attributesGergő Tisza2017-06-081-3/+5
| | | | | | | | | | | | | | | | | | | | | | We have several types of change lists (old RC/watchlist/related changes, enhanced RC/watchlist, history) with slightly different HTML, each with their own idiosyncracies. JavaScript code trying to identify lines by log ID / revision ID has to jump through all kinds of hoops to work with that. To simplify the lives of frontend / gadget maintainers and provide something approaching an API for these pages, we now expose the basic attributes of each change line (revision ID for edits, log type/action and ID for log events) as data attributes. The OldChangesListRecentChangesLine, EnhancedChangesListModifyLineData, EnhancedChangesListModifyBlockLineData, PageHistoryLine, ContributionsLineEnding and DeletedContributionsLineEnding hooks are updated accordingly. New hooks (LogEventsListLineEnding and NewPagesLineEnding) are added for the change list pages which did not yet have them. Change-Id: I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35
* Whenever possible, reuse User objects in unit testsOri Livneh2016-05-261-14/+4
| | | | | | | | | | | | | The unit tests spend nearly half of their run time resetting the user table for each test. But the majority of tests do not depend on the user table having the exact value that the setup code resets it to, and do not need to modify the user objects they require to run. Fix that by providing an API for tests to get User objects, and to indicate whether the User object will be subject to destructive modification or not. This allows User objects to be reused across multiple unit tests. Change-Id: I17ef1f519759c5e7796c259282afe730ef722e96
* Remove explicit tabindex from diff linksDerk-Jan Hartman2016-05-251-1/+0
| | | | | | | | | | These were added to Special:RecentChanges in 2004, but it doesn't match what we do in any of the other lists. For accessibility purposes, in flow indexing is preferred these days, or alternatively a JS controlled roving tabindex, but this was neither. Bug: T116127 Change-Id: Id455fafe4bdea40fb5988bdec14eed672844c8e3
* phpunit: Abstract user-lang override in MediaWikiTestCaseTimo Tijhof2016-03-091-2/+2
| | | | | | | | | | | Removed redundant set up in these classes (same as their paren class MediaWikiLangTestCase does already). * BlockTest * ExportTest * MWTimestampTest * TitlePermissionTest Change-Id: I28d18cb797bb249981727b02dffce4f0d8682b02
* ChangesList: Add support for context source in ChangesList::flag()Timo Tijhof2016-03-081-2/+2
| | | | | | | | | | This way the messages are generated in the correct language instead of relying on the user language from global context. This should ideally become a non-static method at some point, but currently there currently many out-of-class callers. Change-Id: Ifb1756c1a3bddc717387ed66a58dedd4c1a7dab9
* Convert all array() syntax to []Kunal Mehta2016-02-171-7/+7
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Add more test cases to OldChangesListTestaude2015-10-061-0/+19
| | | | | | | * test for watchlist css class * test for number of watching users Change-Id: I6aea1f5b8479ac3656f0ba27ebfa3800d9bffb4c
* tests: Clean up file headersTimo Tijhof2015-04-011-1/+0
| | | | | | | | | | * Remove redundant @licence/@license from test suite files. They already have full licence headers. And @licence raises a warning in Doxygen. * Fix weird messes of comments inside comments and other things. Change-Id: I38da8ca76330f72b8dc22b0ecf1ea69d5ea55ede
* Use qqx language for OldChangesListTestaude2014-09-181-12/+8
| | | | Change-Id: Icda9d541ea0fc929ab8b9274bbe870eb6278d2ed
* Fix undefined argument in OldChangesListaude2014-09-091-0/+11
| | | | | Bug: 70407 Change-Id: I17bbaeaf7c9cae51e33c859867ef3a3199b68a43
* Add @todo note in OldChangesListTestaude2014-08-291-0/+4
| | | | Change-Id: I7878689bcbd4c3742f3ab042c79d7bc8db07e04a
* Add test case for recent changes flags in OldChangesListaude2014-08-291-1/+20
| | | | Change-Id: I011fcc684ddefda3ba86715e781f97b294240933
* Add $logAction param for test recent changes helperaude2014-08-291-3/+3
| | | | | | to allow testing with various types of log actions Change-Id: Idc78c964a68e98239265aaaa9e7913d477a3298f
* Add some tests for OldChangesListaude2014-07-251-0/+157
Change-Id: I6681ce6aa4e753fef33fe9f4719596d630889da6