aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/changes
Commit message (Collapse)AuthorAgeFilesLines
* recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/Timo Tijhof2024-08-297-1837/+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
* Create a maintenance script to purge expired rows in recentchangesDreamy Jazz2024-08-211-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | Why: * In the CheckUser extension, a maintenance script named 'purgeOldData.php' purges data from the recentchanges table. * This script is run on WMF production daily to ensure private data is purged. * This should instead be in core, so that the functionality can be used when CheckUser is not installed and also not duplicate existing code used for the job that purges the table. What: * Create purgeRecentChanges.php which purges expired rows in the recentchanges table by running the code in the RecentChangesUpdateJob directly (without using the job queue, as there is no need to do that because we are in a maintenance script context). * Add a test for this maintenance script * Test the purging features of the existing job to ensure that this code is reliable. Bug: T373032 Change-Id: Id32780c00b053d7fec94a00812f8d40a6bf2e40c
* Add namespace to WikitextContentEbrahim Byagowi2024-08-061-0/+1
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* Merge "RecentChange: Replace use of legacy error arrays"jenkins-bot2024-07-101-22/+21
|\
| * RecentChange: Replace use of legacy error arraysBartosz Dziewoński2024-07-091-22/+21
| | | | | | | | | | | | | | | | | | | | | | Replace uses of soon-to-be-deprecated methods: * ApiBase::errorArrayToStatus * PermissionStatus::toLegacyErrorArray Deprecate and replace uses of: * RecentChange::doMarkPatrolled Change-Id: I2311d1fa3772ba6be378ad6f497ed4c0df9b7aa8
* | Replace User, Title, and WikiPage in more signaturesDaimona Eaytoy2024-07-101-2/+1
|/ | | | Change-Id: I04e408e734edc5498c32c4433f02da613bbfafa6
* RecentChangeTest#testDatabaseRoundTrip: Conditionally disable temp user featureKosta Harlan2024-06-271-1/+7
| | | | | | | | | | | | | Why: - We cannot save an RC entry when temp user feature is enabled What: - Disable auto-create temp user when the user ID in a test case is 0 Bug: T365669 Change-Id: I4191416cb9b80713ed67db71bcd0c7d68c95dde6
* phpunit: Fix tests relying on implicit wgScript/wgArticlePathTimo Tijhof2024-05-052-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-165-37/+37
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace includes/contextJames D. Forrester2024-02-083-0/+3
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* tests: Set rc_log_type in RecentChangeTest for log eventsUmherirrender2023-12-121-0/+4
| | | | | | | | | When running tests together with the CheckUser extension there is a database error, for RC_LOG both fields must be not-null Error 1048: Column 'cupe_log_type' cannot be null Function: MediaWiki\CheckUser\Hooks::updateCheckUserData Change-Id: I188df89b75a57aa1cc82c77f5c925bee634501cb
* Replace a few manually crafted assertTrue assertionsthiemowmde2023-11-231-4/+4
| | | | | | | … replace them with the named convenience methods provided by PHPUnit. Change-Id: Ib46dbc3ab7926cf176477254f466b9bdd3be7c46
* Drop RecentChange::getPerformer(), deprecated since 1.36James D. Forrester2023-09-271-17/+0
| | | | Change-Id: I10cd61f6088da3069d7e29e5fe4355747e83236e
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-193-0/+3
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Reorg: Move MWTimestamp to MediaWiki\UtilsAmir Sarabadani2023-08-192-0/+2
| | | | | Bug: T321882 Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
* EnhancedChangesList: Use HTML/CSS for collapsingFomafix2023-07-131-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The collapsing on the enhanced changes list now works without JavaScript. Keyboard navigation is still supported but only the space and not the return toggles the collapsing toggle button. The <input type="checkbox"> element needs an unique identifier in the `id` attribute and the same value must be in the `for` attribute of the <label> element. A simple counter in the class EnhancedChangesList starts twice from the beginning if the recent changes get included as: {{Special:RecentChanges|enhanced=1}} {{Special:RecentChanges|enhanced=1}} Therefore a random value is used as checkbox identifier. The module 'jquery.makeCollapsible' and its classes `mw-collapsible`, `mw-collapsed` and `mw-collapsible-toggle-collapsed` are not needed anymore. The icons from module 'mediawiki.icon' are directly included because the module has fixed selectors which do not fit here. Bug: T172618 Change-Id: Iafd27e5d760b78ae386d833946005f86cee8dd64
* Merge "tests: Make some PHPUnit data providers static"jenkins-bot2023-05-201-1/+1
|\
| * 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
* | rcfeed: Add 'notify_url' and 'title_url' to MachineReadableRCFeedFormatterTimo Tijhof2023-05-191-1/+90
|/ | | | | | | | | | | | | | | | | | * Move the current URL logic from IRCColourfulRCFeedFormatter to a new method RecentChange::getNotifyUrl (covered by tests now). * Re-use this method in MachineReadableRCFeedFormatter so that the diff/patrol/rcid etc URL is also available in the modern JSON-based EventStreams service. And in particular to allow porting of the legacy irc.wikimedia.org backend to a much simpler one that is based on this. * Also expose a title_url field which was previously missing, and made consumption of the data needlessly difficult. Bug: T234234 Depends-On: Id740134ef30b2276688d7b7caedb6bb652158761 Change-Id: Ic3e0aebdb61b5c0e5fbed08656db4a1e90b67518
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-5/+5
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Allow marking recent changes about logged actions with bot flagMatěj Suchánek2023-03-131-1/+8
| | | | | | | | | There was no clean way to do this but using the global state. The parameter is three-state to keep backward compatibility. Bug: T304428 Change-Id: I01c5f8e9646cbe861516100c3b8d165aefb95ca0
* Reorg: Namespace the Title classJames D. Forrester2023-03-026-0/+7
| | | | | | | | | | | | | | | | | | | 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
* Merge "Reorg: Move PageProps to page/ and namespace it to MediaWiki\Page\"jenkins-bot2022-12-111-0/+1
|\
| * Reorg: Move PageProps to page/ and namespace it to MediaWiki\Page\Amir Sarabadani2022-12-091-0/+1
| | | | | | | | | | | | | | | | We should slowly migrate page/ to have proper namespace too but that'll be pretty big. Bug: T321882 Change-Id: I3e57be8aa8ac08971f190233196e84ea33023d4a
* | Suppress RecentChange::doMarkPatrolled when autopatrol is requestedMatěj Suchánek2022-12-031-24/+6
|/ | | | | | | | | | | | | | The result of the method has been inappropriate and surprising since rc_patrolled was changed to distinguish between manually patrolled and autopatrolled changes (T184791). When called with $auto = true, it would mark the change as manually patrolled (not autopatrolled), but it would not log it as such in patrol log and would still require 'autopatrol' right (not 'patrol'). Change-Id: I0bd6f2cf317d2b1c8dd50b7998724a57f5f549fb
* tests: Replace assertEmpty with assertSameUmherirrender2022-11-251-1/+1
| | | | | | | assertSame avoids use of loose comparisons and allows to check the expected type Change-Id: If821d1be2bc1ff9f8b70968a339f33c7a8e8880a
* tests: Upgrade PHPUnit from 8.5+ to 9.5+Daimona Eaytoy2022-10-081-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | * DeprecatedHooksTest: Don't use assertContains(). * Replace uses of deprecated asserts: - assertFileNotExists() -> assertFileDoesNotExist() * Update hierarchy of MediaWikiPHPUnitResultPrinter, since ResultPrinter is an interface in PHPUnit 9. * Remove temporary forward-compat methods. * Remove directories that don't exist from tests/phpunit/suite.xml, since they now make PHPUnit exit: - tests/phpunit/skins, it used to have SideBarTest, then moved to tests/phpunit/includes/skins - tests/phpunit/documentation, it used to have ReleaseNotesTest, then moved to tests/phpunit/unit/documentation * Update configuration with --migrate-configuration and reformat. * Avoid redefining getMockBuilder() in ActionModuleBasedHandlerTestTrait, use a @method annotation instead. * In RCCacheEntryFactoryTest, avoid using internal PHPUnit logic for HTML validation, and use native PHP methods instead. The code was copied from Xml::load (moved to \Xml\Loader::load in PHPUnit 9) and simplified for this use case. Bug: T243600 Bug: T262076 Change-Id: I851b9158b73d0cfc315eed9d63b15c54b05895e3
* tests: Replace assertRegExp with assertMatchesRegularExpressionDaimona Eaytoy2022-10-073-24/+24
| | | | | | | | | | | | | | | | | | 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: Replace deprecated WikiPage::factoryUmherirrender2022-09-021-1/+1
| | | | | Bug: T297688 Change-Id: Ic84d491c5603f3590e26cb56a305508b2b0ca109
* tests: Migrate `setMwGlobals()` to `overrideConfigValue(s)()`Derick Alangi2022-07-233-10/+8
| | | | | | | | | | | | | | 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
* Replace trivial usa of mock builder with createMock() shortcutThiemo Kreuz2022-07-151-11/+1
| | | | | | | | | | | createMock() does the same, but is much easier to read. A small difference is that some of the replacements made in this patch didn't use disableOriginalConstructor() before. In case this was relevant we should see the respective test fail. If not we can save some CPU cycles and skip these constructors. Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-07-066-14/+14
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
* tests: Use WikiPageFactory to create WikiPage objectUmherirrender2022-06-261-2/+2
| | | | | Bug: T259948 Change-Id: I9afcf3b845306f81ee5ca156553256e6c38df3a0
* tests: Change use of AtEase to at operatorTimo Tijhof2022-02-241-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359. Per T253461, not mass-changing source code, but the use of the native error silencing operator (@) is especially useful in tests because: 1. It requires any/all statements to be explicitly marked. The suppressWarnings/restoreWarnings sections encourage developers to be "lazy" and thus encapsulate more than needed if there are multiple ones near each other, which would ignore potentially important warnings in a test case, which is generally exactly the time when it is really useful to get warnings etc. 2. It avoids leaking state, for example in LBFactoryTest the assertFalse call would throw a PHPUnit assertion error (not meant to be caught by the local catch), and thus won't reach AtEase::restoreWarnings. This then causes later code to end up in a mismatching state and creates a confusing error_reporting state. See .phpcs.xml, where the at operator is allowed for all test code. Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
* tests: Replace some usages of Wikimedia\(suppress|restore)Warnings()Reedy2022-02-241-2/+3
| | | | Change-Id: I361fde0de7f4406bce6ed075ed397effa5be3359
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-272-5/+3
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Title: Make use of BacklinkCacheFactory serviceDerick Alangi2021-09-091-1/+5
| | | | Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
* build: Updating dependencieslibraryupgrader2021-07-225-5/+5
| | | | | | | | | | | | | | 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 WikiPage::doUserEditContent() instead of ::doEditContent()DannyS7122021-06-281-2/+10
| | | | | | | | Results in passing a user where previously the fallback to $wgUser was being used, mostly in tests. Bug: T255507 Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
* Hard deprecate RecentChange::getPerformer()Roman Stolar2021-06-021-0/+5
| | | | | | | Added deprecation warning Bug: T276412 Change-Id: I642a2903f7a1d6861dd5e50e8754980adc937c53
* Remove some unneeded uses of full User objectsDannyS7122021-05-221-4/+3
| | | | Change-Id: Ib86399445a77d3005f23ae87d87f3cf742b13b1f
* build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0James D. Forrester2021-04-291-2/+2
| | | | Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
* Merge "RecentChange: replace Title in method signatures"jenkins-bot2021-04-261-53/+109
|\
| * RecentChange: replace Title in method signaturesdaniel2021-04-261-53/+109
| | | | | | | | | | Bug: T278459 Change-Id: I144ea130f29ec437302649d86494034af044c524
* | Replace PHPUnit ->returnValue() with ->willReturn() shortcutThiemo Kreuz2021-04-223-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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-162-2/+2
|/ | | | | | | | | | | | 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
* Merge "Convert ChangesListStringOptionsFilterGroupTest to pure unit tests"jenkins-bot2021-04-141-276/+0
|\
| * Convert ChangesListStringOptionsFilterGroupTest to pure unit testsDannyS7122021-04-141-276/+0
| | | | | | | | | | | | | | | | | | | | No integration needed, as long as we don't invoke the real constructor of ChangesListSpecialPage, which we can avoid by using a mock Plus a tiny bit of cleanup - don't declare multiple variables at the same time Change-Id: Iac9d04e75019d9ea092321481b87756a9bc03055
* | Merge "Remove $actor field from UsererIdentityValue"jenkins-bot2021-04-141-2/+2
|\ \ | |/ |/|
| * Remove $actor field from UsererIdentityValuedaniel2021-04-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code that needs to store an actor ID in the database to represent a UserIdentity, or needs to construct a UserIdentity based on an actor ID loaded from the database, should use the ActorNormalization service. Note: The getActorId() method is removed from the UserIdentity interface, but all concrete classes continue to support it for now. UsererIdentityValue::getActorId() is hard deprecated and should be removed in 1.37. It always returns 0. User::getActorId() is not deprecated at this point. Bug: T274179 Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237 Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1