Commit graph

582 commits

Author SHA1 Message Date
jenkins-bot 68d90d69a7 Merge "Make DB tests more robust" 2023-09-01 13:33:23 +00:00
Umherirrender 0b95ded538 tests: Small changes to DiscussionParserTest
- Remove set of $wgDiff, not used in core and seems not needed
- Avoid array_keys on foreach
- Save settings directly by UserOptionsManager for the fresh user
- Combine calls to overrideConfigValue into one
- Referer core config via MainConfigNames
- Remove unneeded reset after overrideConfigValues, get reset there
- Reset specific service and not all

Change-Id: Ia00efae85e17dfac1768b12b35f44eb834f879ec
2023-08-24 23:31:36 +02:00
jenkins-bot 38e9654796 Merge "Drop dead code" 2023-08-23 15:06:33 +00:00
Daimona Eaytoy 7b1a9582b2 Make DB tests more robust
In EventMapperTest, suppress notifications created by calling
getExistingTestPage. So far, this test only worked because the existing
test page is created in addCoreDBData (and not inside the test), but
this will no longer be the case after core change
I308617427309815062d54c14f3438cab31b08a73. Clear the PageSaveComplete
hook handlers to prevent that.

DiscussionParser has a static cache of revision data that can become
stale when data is deleted between tests (because revision IDs can be
reassigned to different pages, similar to T344124). This cache seems
needed, and converting the class to a service seems hard, so add the
page title to the cache key to try and avoid collisions. This can still
break if two tests are using the same page, which is hopefully quite
unlikely.

Change-Id: Ic4cbd8ff424e1260544ff9754e0c89dd4bb2f733
2023-08-19 19:59:51 +00:00
James D. Forrester da2fbe366f Switch uses of IDatabase to namespaced version
Bug: T344536
Change-Id: I6f4b158bdc3ef20a1660e66accca0ffc17104f49
2023-08-19 15:01:58 +00:00
Reedy 8f44150300 And a few more namespaced classes...
Change-Id: I57b56d285bac4b41e81f656f3c1ddceee4620fb5
2023-08-18 22:27:18 +01:00
Reedy b003945c34 Namespace a few more classes
Change-Id: Ie233a4c8291432da3bd25d29337db52a2e97b540
2023-08-18 21:48:15 +01:00
Reedy e576cbdca0 Namespace some more classes
Change-Id: If1405788a4adb550e8a7e8c58b0c2c55cf10ea67
2023-08-18 21:24:59 +01:00
Reedy 1bc5b6daf8 Namespace classes that need aliases
Change-Id: Ieeeaf80d04b060d6dbca1959d5e66f4c69c5a7f2
2023-08-18 19:00:41 +01:00
Jon Robson 75b6465876 Drop dead code
This code has been moved to Minerva and is no longer serving any
purpose. The handlers are replaced with an already standardized
mw.hook for Minerva to subscribe and respond to.

Bug: T342907
Depends-On: I55c18cf723a32f80b93a01dd0687e005162c4e93
Change-Id: I2f923e509d24524a2375ffbe6b3ef336487574bb
2023-08-17 13:05:12 -05:00
jenkins-bot 078788f411 Merge "Create HookRunner class and the hook handler interfaces" 2023-08-16 05:26:06 +00:00
Daimona Eaytoy ef50bfeda5 Make Title and Revision caches proper services
Singletons are bad, amongst other reasons, because they're never reset
in tests. They can therefore occasionally cause test failures if the
cached data stored in one of these singletons becomes stale.

As noted on the task, ideally these two classes shouldn't exist at all,
and core should be responsible for caching the information it deems
expensive to compute.

As a temporary (TM) workaround, make both classes actual services, so
that the setUp/tearDown logic in MediaWikiIntegrationTestCase can
properly reset them between tests.

Dependencies are intentionally not being injected, precisely because
these classes should just be deleted, not improved.

Bug: T344124
Change-Id: I58b8d9610f9447468235b94d25732528ab6acce6
2023-08-14 17:41:23 +02:00
Umherirrender 9de512d59c tests: Resolve phpunit filename deprecation errors
PHPUnit wants the filenames of the tests to match the class name being
tested.

Bug: T337333
Change-Id: I44f626d1bfdf151fecafc29c51b2cf2bb90481b0
2023-08-12 21:07:15 +02:00
Daimona Eaytoy 9f44f98e81 Do not assume what user IDs might be in DiscussionParserTest
The test was assuming that the ID 1 belongs to a user other than the one
being created in the test. This is not necessarily the case, so make it
use an ID that is guaranteed to be different.

Also rename the test fail to avoid a PHPUnit deprecation of test class
name not matching file name.

Bug: T342428
Change-Id: Ied1869e380b023c1a726a5be610e1de1b68c78c0
2023-08-07 16:27:28 +02:00
Daimona Eaytoy f7b0638ff0 Mock DB services in NotificationTest::testNewFromRowWithException
The test doesn't need the database, but it's currently trying to use it.
Mock all services used by EchoDbFactory to avoid that (the Factory
cannot be mocked directly because it's created with a static method and
not injected).

Change-Id: I359489ed3f8de6e868a590d5c7c02f81f0a2049d
2023-08-06 22:48:58 +02:00
Umherirrender e52a792060 Create HookRunner class and the hook handler interfaces
Bug: T315938
Change-Id: Iffa2b409502b4269c9746e0304feb4aaee37a86e
2023-08-06 10:30:46 +00:00
jenkins-bot 7d765515b7 Merge "Avoid DB access in non-Database tests" 2023-08-05 04:17:03 +00:00
bwang a5d62502ad Finish updating echo tests to use new MobileFrontend icon class
Change-Id: I304f894c7b55544b7907ee81525604811db6e8e1
2023-08-04 13:41:17 -05:00
Daimona Eaytoy 713f60aaa5 Avoid DB access in non-Database tests
Use mocks when possible, and add the test to the Database group
otherwise.

Also rename 2 test files to avoid a PHPUnit deprecation of file name not
matching class name.

Change-Id: I16b2392daf01f63511c82b4ed0e67a38e35ddbe1
2023-08-04 02:31:24 +02:00
bwang ddaf43c5a0 Update notification badge to not rely on mw-ui-icon
This will essentially all be deleted after I55c18cf723a32f80b93a01dd0687e005162c4e93, but thats fine\

Bug: T343053
Change-Id: Ifb382af388cdc24dc1ecef105ec89c9129194c19
2023-08-02 19:10:34 +00:00
jenkins-bot 8b365dca6f Merge "tests: Call editPage() with WikiPage when used for same page" 2023-07-17 20:48:18 +00:00
Daimona Eaytoy 0d8422a569 Avoid DB access in tests when possible
Use mocks where that makes sense, and add `@group Database` otherwise.

Change-Id: I8f8ec8f4b2c73066cc8e7a6f8e38b3fc286a1070
2023-07-17 20:12:04 +02:00
Umherirrender 36970ce54c tests: Call editPage() with WikiPage when used for same page
When calling editPage() with a string it converts it to a WikiPage each
time it is called. When edit a page only once that is okay,
but when adding more revision to the same page it is better to pass a
WikiPage instead to allow reuse of internal states of WikiPage to speed
up the tests

Change-Id: Iac4ef3a3838ba22cd98b944e3ac7f596d540b405
2023-07-15 22:32:16 +02:00
WMDE-Fisch ef8a472299 selenium: run tests concurrently
Bug: T226869
Change-Id: I55572d5427877364c21631db2f44f8d39b774f95
2023-06-29 15:30:28 +02:00
Daimona Eaytoy baf711c3c5 Replace remaining usages of deprecated MWException
Bug: T328220
Change-Id: I97ea68525392e921b970d15b5d5ffd9c89bae452
2023-06-09 02:23:08 +02:00
Timo Tijhof c51bb93320 tests: Modernize test syntax
* Remove redundant file closure.
* Remove needless QUnit.newMwEnvironment() calls as the tested
  methods don't alter mw.config or mw.messages. Slow, as per
  https://gerrit.wikimedia.org/r/c/mediawiki/core/+/912936/

Change-Id: I61bf03325d5067568d057ff2af6bf65f279a8a84
2023-06-02 16:09:38 +01:00
Umherirrender 680e91c75c tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I8b6fbfc300d62a10da770c8a1ca61756c7d7bf59
2023-05-20 20:36:33 +02:00
Kosta Harlan 53efddc825
Don't send page-linked notifications for pages created by bot users
Bug: T318523
Change-Id: I704a2912e0a8b0e996d4e4e0a73f4ed3b9ccf6be
2023-04-28 12:13:04 +02:00
Kosta Harlan 016b25b43a
tests: Add namespace for UserLocatorTest
Change-Id: I329801c0f7fe47730174f533fb5df683f42a8566
2023-04-28 11:58:56 +02:00
libraryupgrader c59fb68583 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 39.0.0 → 41.0.0

npm:
* http-cache-semantics: 4.1.0 → 4.1.1
  * https://github.com/advisories/GHSA-rc47-6667-2j5j
* ua-parser-js: 1.0.2 → 1.0.34
  * https://github.com/advisories/GHSA-fhg7-m89q-25r3

Change-Id: I1844dc37fc9aed2a3c921b6ae7bf1a0c3e952a18
2023-03-12 01:08:02 +00:00
Dreamy Jazz 62c9c01dde Test ServiceWiring.php
Test ServiceWiring.php using tests copied from CentralAuth. Because
phpunit does not support marking a file as covered, the ServiceWiring
file is ignored for code coverage as the tests should partly cover
the file.

Change-Id: I3ea5ae553d17e17680fcac4d92746fc7ce282eaa
2023-01-25 03:56:06 +00:00
Umherirrender 039e2d2962 Replace deprecated Language::factory
Bug: T325986
Change-Id: Ibeb4af25184dc09a735f4f67457ab72a4139c25d
2022-12-28 20:19:01 +01:00
Umherirrender bb6cb2de0b tests: Replace assertEmpty with assertSame
assertSame avoids use of loose comparisons and
allows to check the expected type

Change-Id: I7220be39f824226f55d966474b58ac12491910a3
2022-11-24 23:03:18 +01:00
Reedy a101ce674c Fix and disable some phpcs exclusions
Change-Id: I2ecaf71c8836d627f20629d667b78ffbf420e4ee
2022-11-12 17:58:13 +00:00
Reedy 5611662f06 Namespace Model
Depends-On: Id28792658de950b99a8786f881563476def59eba
Change-Id: Ib57ea2db947285946f31fa9912b37181044df9d3
2022-11-10 14:25:42 -07:00
thiemowmde cfa424f16b Make use of the ?? and ??= operators where it makes sense
?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: If4145c48eb374aa8e5deeb38aecb27c6c8905382
2022-11-09 14:40:52 +01:00
Fomafix 096e4a709f Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

Change-Id: I395e791aed6cc99b7ce1273f51c292e29360443a
2022-11-08 16:41:24 +00:00
Reedy c85fe25fe7 Namespace Mapper
Change-Id: I8a02082466ef39db32ffa7562b02db61929346cd
2022-11-04 18:05:34 +00:00
Reedy 0f0c6c4fa6 Namespace Iterator
Change-Id: I87fa703da9e7725370d72c58fc40eb204a309e67
2022-11-02 16:51:39 -06:00
Reedy 3609edf153 Namespace Cache
Change-Id: I8ead3ee485528f08f71c21cf401880bf369dbeac
2022-11-02 16:37:48 -06:00
jenkins-bot f4a68c4c77 Merge "Namespace Controller" 2022-11-02 22:34:13 +00:00
jenkins-bot 32d58a5751 Merge "Clean up test case" 2022-11-02 21:44:48 +00:00
daniel 16425ff5ee Clean up test case
- Don't manipulate $wgHooks directly, use setTemporaryHook.
- Avoid premature access to MediaWikiServices from data providers
- use overrideSettings instead of setMwGlobals

Needed-By: I0ebba9a29f81b0d86ad8fd84d478fb244f9e9c15
Change-Id: I52b9251793a5d559658fcf1e0d20f5a497e5fc43
2022-11-02 21:55:56 +01:00
Reedy d3cc06cc6a Namespace Controller
Change-Id: Ice356e774c153c353eb6ed71b8a02afd1ad1e654
2022-11-02 14:52:29 -06:00
Reedy fb4478454d Namespace Gateway
Change-Id: I7501be6e57cec92b2b4175b8772d213c7fd031d4
2022-11-02 14:52:04 -06:00
Reedy 7619a76877 Namespace Echo Formatters
Change-Id: I5bf398cdb76a577543f6526ac1bee4a73897103d
2022-11-01 21:20:06 -06:00
Reedy 56dfaea949 Convert 9 hooks subscribers to HookHandlers
Bug: T315938
Change-Id: I4d061216da8a492fd0d28518d55e67f92e38ee78
2022-10-31 17:15:17 -06:00
Thiemo Kreuz db79d76d83 Use PHPUnit's shortcuts where it makes sense
Notably: any() is the default anyway. It doesn't really make the
tests more specific or better readable when we repeat it all the
time.

Change-Id: I56d201bfce454587b00015b7208f313dd8ed9624
2022-10-26 11:53:57 +02:00
jenkins-bot 7b68f3328b Merge "Namespace Api classes" 2022-10-15 18:04:20 +00:00
Brian Wolff dbe112dfa8 Tests: More complete mock to prevent php 8.1 warning
fixes:
ContainmentSetTest::testCachedListInnerListIsOnlyCalledOnce
strtr(): Passing null to parameter #1 ($string) of type string is deprecated

Change-Id: I9bb916383eda1176a2d56c06770a60c28431dfda
2022-10-03 11:50:04 -07:00