Commit graph

33 commits

Author SHA1 Message Date
Reedy
b52a8addf5 Drop writeapi userright
Bug: T294397
Depends-On: Ib34228a18917e404517d45e539bd786419d9c401
Change-Id: Ifad2edc782b36d21c8c67fecde7f011dce02c11b
2024-07-31 11:10:50 +00:00
Kosta Harlan
a64e3d6c3a ApiRevisionDeleteTest: Use registered authority for tests
Why:

- Anon authority will generate manual log entries with an anonymous
  actor, which won't work with temp accounts enabled

What:

- Switch test cases to use registered authority mock

Bug: T365669
Change-Id: I4d3a79506d2f1fc744fc32b75e560f084738bdd7
2024-06-26 10:55:32 +00:00
Reedy
75640200fb tests: Namespace api tests
Bug: T357823
Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
2024-02-18 15:47:04 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Umherirrender
7cdd690465 tests: api: Replace Title::newFromText with Title::makeTitle
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
2023-07-30 17:15:09 +02:00
Bartosz Dziewoński
1048db795b API tests: Assert error codes, not error messages
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
2023-04-26 19:36:29 +02:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
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
2023-03-02 08:46:53 -05:00
Mark A. Hershberger
2e07010654
ManualLogEntry::getComment() should always return string
So, typehint setComment and then fix tests so they always pass a summary.

This also introduces an api change.

Bug: T311567
Change-Id: I478e62b6753d6009017ab0acc295e6cee7d3b017
2022-07-09 18:58:19 -04:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
libraryupgrader
5357695270 build: Updating dependencies
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
2021-07-22 03:36:05 +00:00
Petr Pchelko
edb3a9a692 Allow passing mock Authority in API integration tests
This is a demo, a lot of tests could be rewritten as a followup
to pass proper Authority when executing tests instead of writing
globals. Much cleaner imho.

An improvement idea is to allow overriding 'default permissions'
when creating a mock Authority.

Change-Id: I38570024e0d5a67a8e1c52f7456c458090ec2b6e
2021-06-07 11:50:42 -07:00
Roman Stolar
67cc77312f Update DatabaseBlock construct option 'by' and 'byText' usage to use User Identity only
Bug: T283641
Change-Id: Ic6d4a6e10bda0115c87a85d8a9ddfd4098cd1373
2021-06-02 17:01:32 +03:00
DannyS712
95ab3b9f9c Tests: stop calling MediaWikiIntegrationTestCase::editPage() statically
Its not a static method and should not be called as such

Change-Id: I9dfdeed38cba90293b1f8bf1de775b343d2de7a9
2021-05-12 07:37:24 +00:00
DannyS712
b876af50cc Fix order of parameters in assertions
Should be expected, and then actual

Switched some assertEquals to assertSame to fix failing
phpcs sniffs

Change-Id: I7257c5afacd22fed78a58f3cc918b721ac11a46d
2021-05-03 15:50:53 +00:00
DannyS712
6ea78705e2 ApiRevisionDeleteTest: remove use of Revision objects
Since this isn't a test for the Revision code, it should have
been updated to use RevisionRecord a while ago rather
than just suppressing the deprecation, oops.

Bug: T247143
Change-Id: I2daf5ecac7fbc4fea78e98688023090febb90282
2021-05-02 03:31:18 +00:00
Thalia
addb098c39 Deprecate DatabaseBlock methods moved to DatabaseBlockStore
Following 23c3c70d7f, 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
2020-09-13 22:17:27 +00:00
DannyS712
0637d80572 Hard deprecate the rest of the Revision class
Bug: T246284
Change-Id: I126d7892c90aa2200c668b5717820e729613bed8
2020-07-02 09:02:02 +00:00
DannyS712
f8cc519222 Hard deprecate Revision::getPage and ::getComment
Bug: T251853
Bug: T254960
Change-Id: I09fadbebd839a16b46a027f64eaac9a435622321
2020-06-10 04:10:41 +00:00
DannyS712
df7906cd0f Hard deprecate Revision::getContent
Bug: T254703
Change-Id: I50e82d29f87725a2d583a0fc1ebacc467ffee935
2020-06-08 02:44:21 +00:00
DannyS712
cc20c65b23 Hard deprecate Revision::newFromId
Bug: T249021
Change-Id: Iee63d5b0fe00dff9f43fcf5cbf43ac1516978e2e
2020-06-03 02:58:57 +00:00
Thiemo Kreuz
9c57ea2b7f Replace complicated assertions with assertIsString() and such
This patch tries to make assertions in tests more readable by using more
self-documenting assertions as provided by modern PHPUnit versions. Among
a few others, these two main changes are done:

* I found a lot of assertions with the expected value being the *second*
parameter. I did not changed all of them. Only some that can be replaced
with assertNull() and such.

* I try to replace all `assertTrue( is_…() )` with dedicated assertions.

Change-Id: I1fc72188fbd0edacf13886e7f9a9eacbd85f13c2
2020-01-28 19:17:58 +00:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
jenkins-bot
1e2cce13ea Merge "Allow users who are partially blocked to delete revisions." 2019-09-11 08:24:11 +00:00
David Barratt
6b43064e5c Allow users who are partially blocked to delete revisions.
Currently, users who are partially blocked are prevented from deleting
revisions. The system should check to see if the user can edit the page.

Bug: T228486
Change-Id: Id08dfab9b0ebe9721d3552564ee9f9d1e1a4805a
2019-09-11 08:14:48 +01:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
Brad Jorsch
96b60ded77 Fix RevDel API output for formatversion=2
Use booleans, not the old empty-string-or-undefined.

This bugfix is a breaking change, but chances are it won't affect many
clients.

Bug: T153518
Change-Id: If5fa2cdcb973b186349307b29e4266daceef0a9d
2016-12-19 11:48:49 -05:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +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
Amir E. Aharoni
94068c3e81 Fix Generic.Files.LineLength phpcs check under phpunit/includes/api
Bug: T102614
Change-Id: Ic0b3d9b58fee8dc20a976ae65dcb7072a3afc3b1
2015-10-03 17:18:05 +00:00
addshore
0273f2d498 Remove use of deprecated TestUser->user
Change-Id: Iec47ea2609b4d407e827cec5bf2a834b75727005
2015-08-07 17:10:26 +01:00
addshore
dcaa81c743 Fix phpcs errors in tests dir
Change-Id: I79fa3b8f92e958f4a0dc4fe892703f37d711ca95
2014-08-17 22:57:09 +01:00
addshore
dfd4c8c2a2 Use public instead of var in classes
Change-Id: I16d1714ba37667d8c9c7c79a765c7199ea0023e4
2014-08-17 21:07:37 +01:00
Kunal Mehta
a83669c745 Tests for API action=revisiondelete
Change-Id: Ida8acb8a58fe3e871ac30727d90e22fff04f488d
2014-08-04 16:00:16 +00:00