Commit graph

26 commits

Author SHA1 Message Date
Fomafix fd5995b244 Use overrideConfigValue instead of setMwGlobals
Change-Id: I0ca6f1c546b6284d30c9251ee1719baa86e33bfc
2024-08-22 20:02:21 +00:00
Umherirrender 00f58b2d52 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I6fd8bf5240359bf7e2ab23f9581471714f0a01d3
2024-06-10 20:42:18 +02:00
Dreamy Jazz 6f021e90da Make SpamBlacklistTest::testSpamEdit pass when temp accounts enabled
Why:
* SpamBlacklistTest::testSpamEdit fails to run when temporary
  accounts are enabled, because the EditPage object does not have
  the user set as the same as the RequestContext user (which is
  a named test user).
* Making the test pass is necessary for running tests when
  temporary accounts are enabled in CI.

What:
* Set the EditPage context user as the same as the test user used
  for the article context above.

Bug: T355879
Change-Id: I34e0299a9d9e3078f9067390e30dca7ce9665de4
2024-05-04 17:24:45 +03:00
Kosta Harlan 3e0747d103
tests: Pass FauxRequest to TempUserCreator
Needed-by: I99d5973498a89ac227847de5837c0a8e895c28fb

Bug: T343101
Change-Id: If660aad1d0f04f366414084aff3f88484a19d416
2024-03-28 13:44:32 +01:00
Kosta Harlan 0016a9a6f1
tests: Support temp accounts in testSpam()
Why:

- Temp accounts require special handling in the test case, since we call
  SpamBlacklist->filter() directly.
- We want to continue to test both IP editing and temp account editing
  paradigms

What:

- Duplicate the testSpam() method to have one invocation run with temp
  users, and a second one with the anonymous IP editing paradigm
- Have the testSpamAnonEditing use a anonymous user object returned from
  user factory, to avoid ActorStore deprecation warnings where the
  mocked wiki ID is null while the wiki's wiki ID is false
- Rename setUp to a "prepareGlobals" method, and invoke this after the
  enable/disable temp account method. That's needed because
  disableAutoCreateTempUser ends up invoking resetServices()

Bug: T355879
Change-Id: I604c521f00d5cc64b8102c93f9a013bcac557001
2024-03-07 10:53:17 +01:00
Umherirrender fc369e9457 Use namespaced classes
This requires 1.42 for some new names

Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I9a7df2df9407ef10d855bc19db247983682a5fc8
2024-01-05 19:28:12 +01:00
Umherirrender 54bb17f0a0 tests: Use assertStatusOK for better failure messages
Change-Id: I1bd4665024a311c4264b9bb680c6d6b4c31be333
2023-10-27 16:20:53 +02:00
gerritbot effea0bde6 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I36f07ad64f90049b412969654cff0d3da31777e6
2023-08-19 04:19:23 +00:00
Umherirrender 583de1d25b tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I7825cbc1fa46d95e5ad4a13cc3440db323541956
2023-05-20 14:09:37 +02:00
gerritbot a76f8baf06 Update moved class EditPage
See T321882. Moved in Ibefc44eb64aed

Bug: T321681
Change-Id: I8f98cecb9177edb9de973cda7b2e10bb10743483
2023-05-06 21:20:28 +00:00
Reedy 52bb0939d9 Namespace extension
Change-Id: Ie53302078d5f405eaa6caef3b7ef4daebf47d877
2022-04-08 13:41:20 +00:00
Alexander Vorwerk ef084bbead MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: Ie7b8882367285568ac7fcf2a28e1c7931bb5c059
2021-10-12 01:04:44 +02:00
daniel 24d3c2d7c3 Add integration test
This test ensures that SpamBlacklist prevents edits that contain spam.

Change-Id: I18e205752d9c5428bb52ebf41ad10fa29e813247
2021-07-27 10:26:41 +00:00
libraryupgrader 3b79f98ba8 build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: Id3f23569f8c6726382dfc1723516ce093df9adb6
2021-07-24 02:17:52 +00:00
Daimona Eaytoy da1af447e2 Always pass a User object to SpamBlacklist::filter
There are some usages outside of SpamBlacklist that must be fixed. After
doing that, the signature should be updated to make the user
non-optional.

Note: I've changed the signature because external callers only pass the
first two parameters. Hence, it's easier to change it now, add a
User parameter to the callers and then make it non-optional, than having
to pass $preserveLog and $mode in all callers and then swapping the
order (as that would break the world).

Change-Id: I0714eb9dbc6af3c775ab7a81cb4b59e687183f77
2020-11-10 19:13:01 +00:00
daniel 5b0da2baf3 Ensure instance cache does not interfere with tests.
Tests need a way to rest BaseBlacklist::instances, so they can be sure
they operate on a clean slate. This is also needed to ensure they do not
operate on real settings, targetting a real remote host.

Bug: T262443
Change-Id: Ic320f7a72da7f26e0931ce3d393fc5a61d43d4fc
2020-09-29 17:20:44 +00:00
Umherirrender 1cdb1d25c8 Use MediaWikiServices::getMessageCache
This required MediaWiki 1.34

Change-Id: I86291dfaf83cdeeb96693979272bf7d4589d650f
2020-03-14 14:20:50 +01:00
James D. Forrester 5a78869772 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I2e639461d789d0b293d0f97da30a2fcf160804a6
2019-10-11 11:58:00 -07:00
MarcoAurelio 54295ecd04 Use https:// on Wikimedia sites in documentation
Change-Id: I82bcd93e32fce8fe59c5053cc298e84559d32a0b
2019-06-01 10:21:28 +00:00
Umherirrender 2ec8f276bb Add @group Database to unit test
Used database by inserting pages

Change-Id: Id81425fff0a41c651c1967698124246befcdb032
2018-09-15 18:18:04 +00:00
Umherirrender 760df43e2d Add @covers to unit test
Bug: T195163
Change-Id: If480e39821580195846b47c0126761be92fa1376
2018-08-25 06:03:08 +00:00
Kunal Mehta 66e8e29ea6 Unbreak BaseBlacklist::getTypeFromTitle() and add tests
The first part of the title is supposed to be capitalized, so call
ucfirst on it, and then make blacklist and whitelist lowercase. Add
tests to verify the known blacklist and whitelist types are recognized
correctly.

This will make validation of SpamBlacklist messages upon edit work
again.

Bug: T169838
Change-Id: I98688362f222ab65115fbec46e0f67587d19022d
2017-07-08 01:39:16 +00:00
Kunal Mehta e6b3d85641 Fix incorrect @group tag in SpamBlacklistTest
Change-Id: I7dab37ff5a7a88207d8b1148c90d1f6e24f925f6
2017-07-06 03:22:50 +00:00
Umherirrender 83cd96ed55 Split multi variable declaration
Each variable should have a documentation block

Change-Id: I53af14d18d3a11ee38256afe7e9d001a2641e466
2017-06-29 18:53:19 +00:00
Umherirrender 3c4e117932 Add phpcs and make pass
Change-Id: I623a982fe6362daab34906a111d123f19676dc22
2017-06-06 18:29:27 +02:00
Matthew Flaschen e0ffbe322e Import PHPUnit tests from Flow, plus one more
Based on Flow repo as of 6099ce48818c8188709352b592f9da118a361fa5 .
Used under GPLv2+

Change-Id: Ibac17d99e86688ced2989ce9ae45581f09c85bd4
2017-05-01 19:20:14 -04:00