aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/ApiMoveTest.php
Commit message (Collapse)AuthorAgeFilesLines
* block: DatabaseBlock constructor caller migrationTim Starling2025-03-041-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | There's about 100 callers of the DatabaseBlock constructor in core tests, most of them passing an address parameter which needs access to the global service container to parse. Many are passing the constructed object straight to DatabaseBlockStore::insertBlock(). So add insertWithParams() for their convenience, which has some handy shortcut parameters, has service access, and throws on failure. The calling code tends to be shorter than before. For unit tests trying to construct DatabaseBlock objects without a service container, direct construction of BlockTarget subclasses is warranted. Add a default to the $wikiId parameters for their convenience. MockBlockManager had its own 'target' parameter, mixed in with block options, carrying its own special idea of a target, which conflicted with DatabaseBlock's new 'target' parameter. Harmonise the parameters and fix the callers. Bug: T382106 Bug: T385966 Change-Id: I78b45a6003b62962211379c36da5587081f90f00
* PHPUnit: Use FQCN with leading backslash in @covers annotationFomafix2024-11-191-1/+1
| | | | | | | | | | | https://docs.phpunit.de/en/11.4/annotations.html#covers recommends: > Please note that this annotation requires a fully-qualified class > name (FQCN). To make this more obvious to the reader, it is > recommended to use a leading backslash (even if this not required for > the annotation to work correctly). Change-Id: I7eb4b997346387e5799fa27a61ab317573124fd0
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Add namespace to includes/api classesJames D. Forrester2024-09-251-2/+2
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Improve rate limit testsdaniel2024-03-121-13/+17
| | | | Change-Id: I1a33dcc9c09d986b4825d7e6e4f5c5b4fa308dd1
* tests: Namespace api testsReedy2024-02-181-0/+4
| | | | | Bug: T357823 Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-1/+1
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Remove indirect calls to IDBAccessObject::READ_* constantsAtieno2024-01-291-19/+19
| | | | | | | | | We are getting rid of the schema of implementing this interface and calling self::READ_* constants, it's confusing, inconsistent, prone to clashes and isn't really useful for non-ORM systems (which we are not) Bug: T354194 Change-Id: I4c722807b27db4e59f5ba3acc3ddb57fca9140b1
* tests: Remove cleanup of blocks, done by ChangedTablesTrackerUmherirrender2024-01-201-3/+0
| | | | | | | | | | | In DatabaseBlockTest changed from addDBDataOnce() to addDBData() as ChangedTablesTracker cannot reset tables changed by addDBDataOnce() between each test run. Remove also User::clearInstanceCache done together with the deletion as the TestUser class is calling this already between tests. Change-Id: Ibd5e544138a2a9b554abc2dea54a5db38f9a828f
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-211-5/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Migrate callers of DatabaseBlock methods moved to DatabaseBlockStoreTim Starling2023-11-061-3/+3
| | | | | | | | | | * Migrate callers of DatabaseBlock methods newListFromTarget, newFromID, newFromTarget, doAutoblock. * Deprecate DatabaseBlock methods newFromID and getAutoblockExpiry. These are the methods with no extension callers in code search. Bug: T255433 Change-Id: If0358459f53d32e7fe984c2fb8b61e0088f28922
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* tests: api: Replace Title::newFromText with Title::makeTitleUmherirrender2023-07-301-121/+146
| | | | | | | | | | | | | | Parsing titles is expensive, it happens in the test function itself via Title::newFromText and also the called editPage() needs to parse the title, better to pass the title object there. Title::newFromText has a cache, that share the title object between the api code and the test code. Use independent title objects for testing. This requires some Title::READ_LATEST to ensure the changed database after the api call is used. Change-Id: I00c14e270a5f4078f80d78696ca2e39acf138e95
* tests: api: Replace some static function with servicesUmherirrender2023-07-291-1/+1
| | | | | | | Replace User::, Title:: ContentHandler:: calls to the corresponding services Change-Id: I57e47221a00eafac9f171215019cf25e19e1808e
* Replace usages of ApiTestCase::$usersDaimona Eaytoy2023-07-251-3/+4
| | | | | | | Ideally we'd use Authority, but that doesn't always work, so just call the getTest* methods directly. Change-Id: I7f8393bb754beeb319b5555b5dac05265e376a22
* API tests: Assert error codes, not error messagesBartosz Dziewoński2023-04-261-24/+12
| | | | | | | | | | | | | | | Error messages are not guaranteed to be stable, and these tests prevent us from improving them. Error codes are supposed to be stable, so we should be asserting that they do not change (especially since many of them are dynamically generated by the dodgy code in ApiMessageTrait). Introduce helpers assertApiErrorCode() and expectApiErrorCode() to be used instead of the usual PHPUnit assertions/expectations for this case. Change-Id: I752f82f29bf5f9405ea117ebf9e5cf70335464ad
* 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
* Make use of the new PageUpdateStatusdaniel2022-11-301-1/+1
| | | | | | | | PageUpdateStatus provides clean access the the newly created RevisionRecord. Depends-On: Ia08c586198082ea47e8313d0d41835f9830fb29e Change-Id: Id6963842321c4eaa3d7d029ad0b769f73433c103
* tests: Use `overrideConfig(Value|Values)` where neededDerick Alangi2022-07-121-4/+3
| | | | | | | This patch covers: tests/phpunit/includes/actions/ and tests/phpunit/includes/api/. Change-Id: I60d8fb7b8a63b423606db935fa0d24cf859b2512
* tests: Use MainConfigNames constants on overrideConfigValueUmherirrender2022-07-121-1/+2
| | | | Change-Id: Ieeefb88daf55a976883f6e20ef6881c89a7f7630
* PHPUnit: enable main object cache in testsdaniel2022-07-071-2/+0
| | | | | | | | | | | | | | | | | This sets MainCacheType to 'hash', so the main cache is functional within test cases. Between tests we are already calling ObjectCache::clear, so the cache will not leak data into other test cases. It turned out that the way we have been overriding configuration settings in MediaWikiIntegrationTestCase is insufficient, since the overrides would only apply in the main Config object, not in global variables. This means they could not be overwritten with setMwGlobals. So this patch also changes how we apply config overrides for test setup. Config overrides that happen during tests work as before. Depends-On: Ic36e92b73f22fd64e2d0b680d8e900f598158460 Change-Id: Ia60cb0bc18b235f23d9778da8241f65accfc0d35
* PHPUnit: introduce setMainCachedaniel2022-07-071-2/+2
| | | | | | | | | | | | The main object cache is disabled during testing. Some integration tests need it though. This provides a clean way to enable it, to replace the hacks that were used so far. Note that we may want to enable the main cache during testing soon. When that happens, this method is still useful to disable the cache in certain tests, and to set a specific cache instance. Change-Id: I04ae1bf1b6b2c8f6310acd2edf89459d01a9c870
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-4/+3
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Remove or replace usages of "sanity"Reedy2021-11-211-1/+1
| | | | | Bug: T254646 Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
* Update DatabaseBlock construct option 'by' and 'byText' usage to use User ↵Roman Stolar2021-06-021-1/+1
| | | | | | | Identity only Bug: T283641 Change-Id: Ic6d4a6e10bda0115c87a85d8a9ddfd4098cd1373
* Use WatchlistManager in API classesCindy Cicalese2021-04-211-2/+4
| | | | Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
* Deprecate DatabaseBlock methods moved to DatabaseBlockStoreThalia2020-09-131-2/+3
| | | | | | | | | | | | | Following 23c3c70d7ff2, soft deprecate the static methods on DatabaseBlock that have been moved to DatabaseBlockStore: * ::insert * ::delete * ::update * ::purgeExpired Update calls to the deprecated methods from core. Change-Id: I1272eb978594fd4f386bda12cbc24131ad7d882f
* WatchAction: avoid unnecessary UPDATEs when expiry is unchangedMusikAnimal2020-08-111-2/+2
| | | | | Bug: T258649 Change-Id: I0a5a84480bbd630c7dd1744b4316ea31d7bedd5b
* Default to using watchlist expiry of old page when moving pagesMusikAnimal2020-08-051-0/+30
| | | | | | | | | | | | Expiries are copied post-send so as to not slow anything down. Note the expiry feature has been disabled in some unit tests that mock database queries, simply because these tests are so hard to maintain and are very fragile. The logic introduced with this patch is covered by the integration tests. Bug: T257259 Change-Id: I4223eaa6782a319fb684acf656f54b88a92e5288
* Add watchlist expiry support to applicable APIsMusikAnimal2020-07-131-0/+32
| | | | | | | | | | | This introduces an ApiWatchlistTrait that refactors out common code across APIs that allow you to watch pages. Some methods have been migrated from ApiBase and changed completely, but codesearch suggests they aren't being used outside the API modules in this patch. Bug: T248512 Bug: T248514 Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
* Remove use of the Revision object returned in WikiPage::doEditContent (2)DannyS7122020-06-101-1/+1
| | | | | | | | Each file's changes are independent and can be reviewed separately Bug: T251853 Bug: T254952 Change-Id: Ifdc192796f0989c12fda7c0317bf2458874d6e19
* Replace uses and hard deprecate Revision::newFromTitleDannyS7122020-04-181-1/+7
| | | | | | | Also fixed a use of ::newFromId in benchmarkParse and Parser Bug: T249183 Change-Id: I3219a72f1085836205dc497e2236b52db24d7c16
* Add target page as a parameter to `articleexists` messageDannyS7122019-12-201-2/+2
| | | | | Bug: T184357 Change-Id: I350d9a8f1504ca878992340db3dd0d60f73594bd
* Replace setExpectedException with two argsDaimona Eaytoy2019-10-051-15/+22
| | | | | | | | | | | Find: ^(\t*)(\$this->)setExpectedException\(\s+(\\?[a-z\\]+::class),\s+('(?:[^'\\]|\\')+'|"(?:[^"\\]|\\")+")\s+\); Replace: $1$2expectException( $3 );\n$1\$this->expectExceptionMessage( $4 ); +broke long lines manually. Bug: T192167 Change-Id: I5557b4372625def55a53ac637c2f980f51f12933
* Remove unneeded overrideMwServices/resetServicesAryeh Gregor2019-08-291-1/+0
| | | | Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
* Re-apply: Factors out permissions check from User into PermissionManager serviceVedmaka2019-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Was reverted by I549810a4cd2e424cc4a438887d2f24614a24cc00 due to T224607. Original change by Vedmaka Wakalaka was Ia0d840b772ea5f20c9594ce151cc57adc270e48b. Original commit message: The following methods should are factored out of the User class into PermissionManager, leaving only deprecated stubs: - User::isAllowed -> PermissionManager::userHasRight - User::getRights -> PermissionManager::getUserPermissions - User::groupHasPermission -> PermissionManager::groupHasPermission - User::getGroupPermissions -> PermissionManager::getGroupPermissions -User::getGroupsWithPermission -> PermissionManager::getGroupsWithPermission - User::groupHasPermission -> PermissionManager::groupHasPermission - User::isEveryoneAllowed -> PermissionManager::isEveryoneAllowed - User::getAllRights -> PermissionManager::getAllPermissions Depends-On: I7909e9bd6bbfbd708c0a00b861a9b22a38c6665d Bug: T218558 Bug: T223294 Change-Id: I8899240378f636ea70f447616710516c0a3c5c31
* Revert "Factors out permissions check from User into PermissionManager service"Kosta Harlan2019-05-301-3/+0
| | | | | | | | This reverts commit 7faa7a7420866ec685863c1d6c530bd4999da643. Reason for revert: T224607 Change-Id: I549810a4cd2e424cc4a438887d2f24614a24cc00
* Factors out permissions check from User into PermissionManager serviceVedmaka2019-05-291-0/+3
| | | | | | | | | | | | | | | | | | | | | The following methods should are factored out of the User class into PermissionManager, leaving only deprecated stubs: - User::isAllowed -> PermissionManager::userHasRight - User::getRights -> PermissionManager::getUserPermissions - User::groupHasPermission -> PermissionManager::groupHasPermission - User::getGroupPermissions -> PermissionManager::getGroupPermissions -User::getGroupsWithPermission -> PermissionManager::getGroupsWithPermission - User::groupHasPermission -> PermissionManager::groupHasPermission - User::isEveryoneAllowed -> PermissionManager::isEveryoneAllowed - User::getAllRights -> PermissionManager::getAllPermissions Depends-On: I258f02e286b6ba0387e1bff540a744fafb03dc55 Depends-On: Ie4cedf457eaaa93ec3055c37539322855e02ce26 Depends-On: Id274f240d687efa61cb9f7a15033ae2a7a532083 Bug: T218558 Bug: T223294 Change-Id: Ia0d840b772ea5f20c9594ce151cc57adc270e48b
* Rename Block to MediaWiki\Block\DatabaseBlockThalia2019-05-281-3/+5
| | | | | | | | | | | | Keep Block as a deprecated class alias for DatabaseBlock. Update calls to the Block constructor and Block static methods from external classes. Also update documentation in several places that refer to blocks as Blocks. Bug: T222737 Change-Id: I6d96b63ca0a84bee19486471e0a16a53a79d768a
* Fully utilize LinkTarget passed to getRevisionByTitleJason Linehan2019-04-021-0/+1
| | | | | | | | | | | | | | Failure of getRevisionByTitle to pass its LinkTarget argument to newRevisionFromRow resulted in a needless second instantiation of the Title (an extra query). Because newRevisionFromRow needs a Title, not just a LinkTarget, it is unfortunately necessary to call Title::newFromLinkTarget on it for now -- however this does not involve a DB lookup and is on track to be fixed with revisions to the Title class. Bug: T206498 Change-Id: Ic6f98d8fbf66d85121668571c17e148efc5ec2be
* API: Spread autoblocks from action=edit and action=moveBrad Jorsch2019-02-191-0/+33
| | | | | | | | | | The code in EditPage and SpecialMovepage does this primarily in web UI code paths that aren't called by the API. EditPage also has a check in the internal code path used by the API, but ApiEditPage runs its own permissions check first and won't reach that code path. Bug: T216245 Change-Id: I6263c8b60a24f3195dba583463f1ce4b004f82f5
* Ensure calls to Title::getArticleID use the same case as the definitionThalia2019-02-061-10/+10
| | | | Change-Id: Ic92f43c9e9df2782ba20aa28ad9e6d2ef7976d2e
* Deprecate MediaWikiTestCase::stashMwGlobalsAryeh Gregor2018-10-071-8/+3
| | | | | | | | | | | | | | This method encourages directly editing configuration variables. It's a better idea to use setMwGlobals() (or other set wrappers) so that we can be intelligent in the future, for instance resetting services after the config change. Plus, a lot of the callers come out cleaner this way anyway. Depends-On: I8a1e81acc5c42a8d7f30938a72cface0acea4a70 Depends-On: I4105dbcf9c5399fe7239478c460ec57c015a98d4 Depends-On: I1b220996acf2f66cf7b0f092b341584663df32f9 Depends-On: Ie2d1ea65c0cb334bbde1666d00781474b7ac4dab Change-Id: I23d77398e401f4986b1d5bd1c9e11a8a40da16f8
* Test ApiMoveAryeh Gregor2018-04-151-0/+393
One bug caught: the watch and unwatch params were not being honored. They have now been removed. Depends-On: Ia21a974f2b463afc9324182137b95c80db86a6aa Change-Id: I0e214339c9ae3f0fb5a40c88a84190bc32503151