Commit graph

16 commits

Author SHA1 Message Date
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
STran
1a9f6da570 Add tests for temp user flag
- test for temp users in ApiQueryLogEvents
- test for temp users in ApiQueryRevisionsTest

Bug: T353355
Change-Id: I8c1ae26e5566dd8fc2d2817fd3acaa04478d686c
2024-02-14 05:50:08 -08:00
Umherirrender
388b0374fa tests: Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements and changes to docs done manually

Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
2023-12-11 15:59:55 +01:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
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
2023-03-24 02:53:57 +00:00
Máté Szabó
b523ab0081 Parser: Fix extractSections() behavior for PHP >= 8.0
PHP 8.0 changed the behavior of numeric comparisons such that
non-numeric strings no longer weakly equal 0.[1] This breaks the logic
in Parser::extractSections(), which was relying on the old comparison
behavior for section indexes and in turn causes the revisions API to
return a bogus 'nosuchsection' for error when called with rvsection=new.

Fix the logic by explicitly casting the section index to a number, which
will yield the appropriate numeric section index for a numbered section
index and 0 for a non-numeric section index (like 'new'). Also add test
cases for the relevant API module.
--
[1] https://wiki.php.net/rfc/string_to_number_comparison

Change-Id: If32aa4d575cff66bd4eee56f9e3b0b0d9ba04fde
Bug: T323373
2022-11-18 15:23:46 +01:00
Máté Szabó
f15e0a62f9 ApiQueryRevisionsBase: Fix 'rvdiffto' parameter handling on PHP 8.0
The legacy 'rvdiffto' API parameter allows consumers to supply a
revision ID or the special strings 'cur', 'prev', 'next' to
revision-related API modules. This will then be resolved to a revision
and the diff of returned revisions against this revision will be
attached to the response.

On PHP 8.0, this parameter is broken as 'cur', 'prev', 'next' no longer
get resolved to the appropriate revision ID but rather are treated as
invalid literal revision IDs. This is because given an associative array
`$params = [ 'diffto' => 'prev' ];`, the expression `$params['diffto']
!= 0` is false on PHP < 8.0 but true on PHP >= 8.0.[1]

Fix it by also checking whether the parameter value is numeric before
treating it as a revision ID, and add a test case for this logic. To
facilitate testing, convert the counter used by ApiQueryRevisionsBase to
count the number of uncached diffs served in the current response to an
instance variable; it is currently a static variable which persists
across test boundaries.

Change-Id: Ifbe14cd2880c98dddc5577d226bef5878bdd657f

---
[1] https://onlinephp.io/c/81e7b

Bug: T322335
Change-Id: Id5032932842c94f4d3ca3707fbc733f5b9704151
2022-11-03 15:49:04 +01:00
Umherirrender
2909d06a08 Use new namespace for revision related classes
All revision related classes are namespaced MediaWiki\Revision
instead of MediaWiki\Storage since 1.32. The old namespaced
class names are deprecated and only kept for backwards-compatibility.

Bug: T305784
Change-Id: I34e492d84d9fc4bc78481667202716d93b3c43cb
2022-04-14 23:03:43 +02:00
WMDE-Fisch
e686e06c38 Use PageUpdater in API test to add revision
Change-Id: I9ba1357c0556d572594f4750403b24b5b8cdbdc0
2021-11-01 10:49:52 +01:00
DannyS712
b45ddb2ab3 Use WikiPage::doUserEditContent() instead of ::doEditContent()
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.

Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
2021-06-28 00:11:30 -07:00
Brad Jorsch
07842be379 API: Update query modules for MCR
MCR deprecated the Revision class in favor of the broadly similar
RevisionRecord, and more interestingly added the concept of multiple
content "slots" to revisions.

Thus, prop=revisions, prop=deletedrevisions, and so on gain a parameter
to specify which slots are wanted. When this new parameter is not
specified (and any content-related props are specified), a warning about
the legacy format will be issued.

The rest of the modules just needed to call methods or use constants on
RevisionRecord instead of Revision. ApiQueryDeletedrevs wasn't touched,
since it has been deprecated since 1.25 anyway.

This also updates a few non-query modules that don't depend on details
of editing, diffing, or viewing MCR revisions that haven't been figured
out yet.

Bug: T200568
Change-Id: I1327d1784f5cedb006cd74df834cf9a560a77a5d
2018-07-27 23:33:45 +00:00
Reedy
3c27ff94fa Replace WikiPage::doEdit() usages
Update/add some comments

Bug: T145737
Change-Id: Ib3b2b69906074cbb51917dc57204c989fd6c58b2
2016-09-15 21:25:32 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
addshore
d442e88e55 @covers for ApiQuery stuff
Change-Id: Id8a89abd545d8e2a95b1d246776049b9c888e53c
2013-10-24 11:04:00 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Siebrand Mazeland
9f77245218 Update formatting
4 of n.

Change-Id: I23e2409ce9eff14c3434154d236de83c93a92440
2013-02-14 14:10:38 +01:00
Yuri Astrakhan
33979bd5bc API tests to verify basic query functionality (list & props)
* Several tests to verify query with prop=, list=, and generator
* Moved query related tests to query\ dir
* Added a generic ApiTestCase::editPage() to simplify page creation
* Fixed minor warnings complained by jenkins/phpcs

Change-Id: I5e3984d797178ae03f048792c7bac8e6a881aa41
2013-02-08 01:45:19 -05:00
Renamed from tests/phpunit/includes/api/ApiQueryRevisionsTest.php (Browse further)