Commit graph

94 commits

Author SHA1 Message Date
Umherirrender
abf2ea44e8 tests: Handle dynamic created properties on test classes
- Declare missing properties
- Remove unused or avoid set of properties
- Add AllowDynamicProperties

Bug: T314099
Change-Id: Ie631894f2ffbb616f6dd09851405d681f3eb8fcd
2023-01-13 21:03:42 +00:00
Umherirrender
f65e6bb488 Replace deprecated Linker::commentBlock/revComment
Bug: T324906
Change-Id: I8cf96c3b7a03127ce1243f7a7e849b6d5a5d3dfa
2022-12-11 01:33:56 +01:00
Amir Sarabadani
2d60ba0c63 Reorg: Move DummyLinker and Linker to linker/
This feels like a no-brainer unless I'm missing something obvious

Bug: T321882
Change-Id: Id49c3d0dd6ea4593211048850856b5b8e05a8fb3
2022-12-08 06:38:17 +01:00
daniel
8e0ae53482 PHPUnit: introduce clearHooks() method.
Since the introduction of the new hooks stystem, it is not possible to
clear all hooks by setting $wgHooks. This would only clear old-style
hooks. This is becoming increasingly problematic as the new hooks system
is adopted by more and more extensions.

Introduce a method that allows tests to reset many or all hooks.
This isn't needed much in core, but extension tests need it.

Change-Id: Ica3eb88fe23fe822d2aadb96ff5d15f80dce0d7b
2022-11-03 13:40:42 +01:00
Derick Alangi
b6b335b183 tests: Migrate MediaWiki settings to overrideConfig...()
Also, make use of MainConfigNames constants where necessary like in
HashConfig map.

NOTE: Since `wgConf` is not a setting, keep using `setMwGlobals()`
  in this case.

Change-Id: I8d0c718fd02043835fe122d675cce3d759b30330
2022-08-18 17:48:03 +01:00
Derick Alangi
175832a8e9 Migrate usage of setMwGlobals() to overrideConfigValue(s)
Change-Id: I49d97864d8f9d8cadf01b0c0dc653fbac4ca9e94
2022-08-01 06:16:22 +01:00
Umherirrender
047c184bfe tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
2022-07-06 00:44:00 +02:00
EpicPupper
6abc28230b Unify how the term "undelete" is used in the undelete UI
Amend DeleteLogFormatterTest phpunit test with new string

Bug: T307181
Change-Id: I367b78068c8177505651c6d87ce668b36e1ca651
2022-05-16 13:31:01 +00:00
Umherirrender
d7809a41d9 logging: Normalize "infinity" in BlockLogFormatter for pre-T241709 rows
This allows the API to consistently return the new value for old rows.

Bug: T241709
Follow-Up: I36f49dc83718cc78f17fc340e6445030b8fd0c66
Change-Id: Ida69980f62a6ef070ba41b7e826967f424881716
2022-04-12 20:57:18 +00:00
Umherirrender
e247447af0 logging: Remove user_editcount from DatabaseLogEntry query info
The column is now unused. It was used to prefill edit count in User
object before 83e1846 by use of User::newFromRow

Follow-Up: I1b78bad7e1fa43f5f82908567a7daad9c6cc79b9
Change-Id: Iec5eeaa8729a3add46c11cd62dee8aefe2e5e050
2022-04-06 23:40:03 +02:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
Umherirrender
7359c6bda9 Allow DeleteLogFormatter to work with pre-T20361 (April 2009) log rows
The i18n part of T20361 / ec0dd5b adds new log parameter,
logs from before the changes are needed to work with the formatter.

Bug: T289806
Change-Id: I096bc14373cbe038671fc33f651af7e005998a3b
2021-12-04 19:45:51 +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
1782bc7fd4 Remove hard-deprecated LogEntry::getPerformer
Change-Id: Ia2c4819848f5d23d5ceb74aae9c6c5920b8851ba
2021-06-28 18:06:36 -07:00
jenkins-bot
6feb8d7834 Merge "Change "protection level" to "protection settings"" 2021-05-23 12:54:48 +00:00
jenkins-bot
d7a0394e8e Merge "Allow action blocks to be logged via block log parameters" 2021-05-05 21:26:46 +00:00
DannyS712
31676abea5 Add DummyServicesTrait::getDummyInterwikiLookup
Replacing the mock InterwikiLookup used in
MediaWikiTitleCodecTest revealed that that test was,
because of the mock not behaving correctly, testing the
wrong thing - interwiki prefixes are *not* case sensitive,
and are always converted to lowercase in the actual
ClassicInterwikiLookup. Fixed those expectations.

Change-Id: I242431e88860b7700a9f93f77a0fe195fd748800
2021-05-05 10:57:59 -07:00
tsepothoabala
b4a60fecdf Allow action blocks to be logged via block log parameters
Bug: T279560
Change-Id: Icd6ba193a2ce7af83a074cd135470a5097638791
2021-05-05 19:45:52 +02:00
Amir Aharoni
986a4c9459 Change "protection level" to "protection settings"
This was suggested in translatewiki.

Protection is not only about protection level, but also
about its being cascading or not and expiry time. The message
should reflect this. Some messages that are specifically about
level are not changed.

Change-Id: Id9dae220269cda526564c555427e24d880e1a57c
2021-05-04 13:17:36 +03:00
Tim Starling
83e184670c Stop using legacy ActorMigration field "log_user"
Bug: T278917
Change-Id: I1b78bad7e1fa43f5f82908567a7daad9c6cc79b9
2021-04-28 16:29:04 +10:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
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
2021-04-13 18:18:06 +00:00
Reedy
eb41565a9a Tests: Start marking some closures as static
Bug: T274036
Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
2021-02-06 19:57:42 +00:00
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
Thiemo Kreuz
ac205fa84c Fix incomplete/bogus PHPDoc tags in various tests
Most of these are found by the not yet released I10559d8.

I remove the type MockObject in some cases when the calling
code really does not need to know if he get's a mock or the
real thing. However, I do this only in places that are very
closely related to the fixes.

Change-Id: I26a4c3c5a8ae141bf56161b52b54bce7e68f2e30
2021-01-14 19:02:00 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
C. Scott Ananian
3d40c43b1f Deprecate InterwikiLoadPrefix hook
The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is
unidirectional and doesn't support enumerating all valid prefixes
(T270444).  Set/reset $wgInterwikiCache to mock the interwiki table
for parserTests and other unit tests instead.

This is a soft deprecation, as the used-in-production
Extension:Interwiki still uses InterwikiLoadPrefix, although not in a
way that would break Parsoid (since $wgInterwikiCache is set in
production).

Bug: T270444
Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
2020-12-21 19:28:48 +00:00
DannyS712
370856f0cf Remove use of $wgUser from LogFormatterTest, unneeded
Bug: T243708
Change-Id: I4d76ffbec4f094178059d3cccb65bf4837321f08
2020-09-14 20:26:13 +00:00
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Daimona Eaytoy
f5529400cc Stop using assertContains with string haystack
This was done automatically by replacing every assertContains with
string *needle*. Then verifying the results.

Bug: T192167
Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
2019-12-15 00:22:44 +00:00
Thiemo Kreuz
50dca8ed1e Replace some oldskool @see with @inheritDoc
This patch also adds some missing newlines at the beginning of files.

Change-Id: Ifcdf75396c96f17b7bfb103f54bfdf4ba4dfbccc
2019-11-08 18:00:27 +00:00
Max Semenik
dd7026585c Backwards-compatible PHPUnit 8 preparations
This commit splits changes from Ic14f5debc53e55d6714 to reduce it to
only strictly needed things. It can be merged immediately.

Bug: T192167
Change-Id: I8c541a66ea13421dbe7fa51d197d5455cc4786eb
2019-11-02 12:40:07 -07: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
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Aryeh Gregor
e787246ce8 LanguageFactory to replace Language::factory()
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().

Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
2019-10-23 10:48:23 -07:00
Aryeh Gregor
043d88f680 Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

An earlier version of this patch (e4468a1d6b) had to be reverted
because of a massive slowdown on test runs. Based on some local testing,
this should fix the problem. Running all tests in languages is slowed
down by only around 20% instead of a factor of five, and memory usage is
actually reduced greatly (~350 MB -> ~200 MB). The slowdown is still not
great, but I assume it's par for the course for converting things to
services and is acceptable. If not, I can try to optimize further.

Bug: T231220
Bug: T231198
Bug: T231200
Bug: T201405
Change-Id: Ieadbd820379a006d8ad2d2e4a1e96241e172ec5a
2019-10-07 13:18:47 -07:00
Amir Sarabadani
440297fa3a Clean up most of b/c for phpunit4
We don't support phpunit4 anymore:
https://w.wiki/9UT

Change-Id: Ia7c932998f1a49af1e322ab9e1dc249b7bd2e8b2
2019-10-06 00:14:35 +02:00
Ammar
1d59041fc8 Fix permission check on protection log
*I2341e6f inverted the permission check, such that now the link is only shown to unprivileged users

Bug: T234017
Change-Id: I0977f1ab1a72840303aeca2367a30546d83117d4
2019-09-27 09:58:41 -07:00
Brad Jorsch
c29909e59f Mostly drop old pre-actor user schemas
This removes most of the pre-actor user and user_text columns, and the
$wgActorTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_user and rev_user_text remain in the code, as on Wikimedia wikis the
revision table is too large to alter at this time. A future change will
combine that with the removal of rev_comment, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

ActorMigration's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process. Code using
ActorMigration for accessing the core fields should be updated to use
the new actor fields directly. That will be done for in a followup.

Bug: T188327
Change-Id: Id35544b879af1cd708f3efd303fce8d9a1b9eb02
2019-09-09 11:38:36 -04:00
Amir Sarabadani
308e6427ae Revert "Make LocalisationCache a service"
This reverts commits:
 - 76a940350d
 - b78b8804d0
 - 2e52f48c2e
 - e4468a1d6b

Bug: T231200
Bug: T231198
Change-Id: I1a7e46a979ae5c9c8130dd3927f6663a216ba753
2019-08-26 18:28:26 +02:00
Aryeh Gregor
e4468a1d6b Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

Change-Id: Iaa86c48e7434f081a53f5bae8723c37c5a34f503
2019-08-22 14:25:18 +03:00
rxy
0b91327754 Add permission check for user is permitted to view the log type
Note: formatter patch only

Note: cherry-picked I064f563cb here as well

Bug: T222038
Change-Id: I1c4e57a513e3a0e616b862a5b9d684f463ad9981
2019-07-25 20:32:37 +00:00
daniel
20717fd031 LogFormatter::formatParameterValue: handle bad user names
This makes LogFormatter more robust against bad user names coming from
broken log records.

Bug: T224368
Change-Id: Ifce9e86bddba274182253cd25338766e8093d6ad
2019-07-03 18:49:58 +02:00
jenkins-bot
67d01c452d Merge "Tolerate invalid titles in some ChangesFeed and LogFormatter code" 2019-06-24 23:29:11 +00:00
daniel
7271ac0dcd Tolerate invalid titles in some ChangesFeed and LogFormatter code
Bug: T224811
Change-Id: If134e20cc14d80f9186611606df0b860889bd2cf
2019-06-24 23:15:06 +00:00
SBassett
ec104811c6 Revert "Fix testsuites for LogFormatter"
This reverts commit d0c2da8261.

Reason for revert: Original patch set appeared to work then began failing multiple CI builds post-merge.  Simply reverting for now due for T226293.

Big: T226293
Change-Id: I3e33300cecfe87926fcb8851689d67c3b1258b0f
2019-06-22 12:25:33 +00:00
rxy
d0c2da8261 Fix testsuites for LogFormatter
Change-Id: I064f563cb54a50c3292b1f9e24b0bb467f69af9b
2019-06-21 21:55:51 +00:00
Brad Jorsch
144ebd06c7 DeleteLogFormatter: Handle missing ofield/nfield
ofield and nfield may be missing from old log entries. Take that into
account when processing.

Bug: T224815
Change-Id: I06dda3106bab9980f6fa7d515542e94a91c17f64
2019-06-12 23:33:45 +00:00
Roan Kattouw
5ce1e2b743 Linker: Use parentheses by default in userToolLinksRedContribs()
This function had been changed to unconditionally disable parentheses,
but none of its callers load the CSS needed to make that work.

Bug: T220767
Change-Id: I566d65e155258d3bd1a1a06bca9aa2b3a2d417ee
Follows-Up: I6eeeaa3b58d37adb7fefb4cc6915022229b3b324
2019-04-19 15:09:36 -07:00
MGChecker
84c46d38b7 Add separate log action for file reverts
This change s adds 'revert' as a separate log action for file reverts, as it
allows special formatting of log entries and revisions in UI and filtering
for file reverts specifically.

Even though there are no log entries with this log action right now, it does
seem that this was intended as some point, as there are corresponding
test cases in UploadLogFormatterTest, and is listed in
$wgLogActionsHandlers and https://www.mediawiki.org/wiki/API:Logevents
as well. Furthermore, the i18n message 'logentry-upload-revert' already
existed before this change.

Because this functionality can not be provided by tags, the 'mw-undo' tag
is not suited for this use case. However, it could be added additionally to
all log entries with this log action..

Bug: T60209
Change-Id: Ie1ccd8053dc5de58b2297a8460219f0233aab968
2019-03-02 22:16:55 +00:00