Commit graph

615 commits

Author SHA1 Message Date
Fomafix e03f7c3e82 Use overrideConfigValue/overrideConfigValues instead of setMwGlobals
Also use MainConfigNames.

Change-Id: I80d6b3ef9d7b857e35d8f93f424db1cfca1301f6
2024-07-26 12:47:09 +00:00
Željko Filipin 78fe1911a4 selenium: Document when, how and why a test is skipped
Bug: T280652
Change-Id: I835e86ad663d77d2623637a06a27c7a90e007cb6
2024-07-08 15:17:13 +02:00
Wandji69 633682d56d Test:Replace db with getDb method
Bug: T316841
Change-Id: Ia135648c0666632165bfbe29b6587e6676082d54
2024-07-05 17:08:51 +01:00
thiemowmde e87cf704f4 Don't hold reference to MediaWikiServices instance in tests
There is no guarantee the MediaWikiServices instance is still valid.
Other tests can reset it.

Bug: T368390
Change-Id: I92de60b2ba5fb66af957a800ce85773db58303cc
2024-06-26 11:27:22 +02:00
Umherirrender a51c944567 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I3d7a1ffe167b69d3f4ce51d0c248c758e1cdd70c
2024-06-12 20:31:47 +02:00
jenkins-bot 7954f54451 Merge "More specific type hints and type declarations" 2024-06-07 03:06:57 +00:00
libraryupgrader 0d8e740635 build: Updating npm dependencies
* eslint-config-wikimedia: 0.27.0 → 0.28.0
  The following rules are failing and were disabled:
  * modules:
    * no-jquery/no-extend

* grunt-stylelint: 0.19.0 → 0.20.0
* stylelint-config-wikimedia: 0.16.1 → 0.17.1

Change-Id: I45a64d80ef5aa50b4a1abd871605f52682ab9b5b
2024-06-06 16:47:09 +00:00
Ed Sanders 2dd3780966 ESLint: Prefer arrow callbacks (autofixed)
Change-Id: I01da3714b1f5d9b1926ee4394c15f594efb01245
2024-06-03 14:49:38 +01:00
Ed Sanders 1d3be2c605 ESLint: Autofix no-var errors
Keep the rule and prefer-const disabled as they will
require manual fixing.

Change-Id: Idd31eb7d7a456b10c07b905b4b837dd4c890eb71
2024-06-03 13:22:48 +01:00
jenkins-bot b721cc23df Merge "configure main hook handler to pass StatsFactory service" 2024-05-27 11:48:12 +00:00
thiemowmde 7e3d73c11b More specific type hints and type declarations
Most notably:
* Use the much more narrow UserIdentity interface where possible.
* Make array type hints in PHPDocs as specific as possible.

Change-Id: Id189da4028b7874909277881dcf6539169dd13b6
2024-05-16 10:32:19 +02:00
thiemowmde 95fddc9228 Make all @covers tags in tests absolute
This is much less confusing for certain IDEs. Without the leading
backslash it looks like a relative patch, but isn't actually one.

Change-Id: I9c9f41869ea0ed063a67f8e65807833d1b3dba2b
2024-05-11 15:18:46 +00:00
Siddharth VP e27f4937ff Add API module for sending notifications
Allows users to send notifications to themselves (T306211). For sending
notifications to others, a new permission is created (echo-create),
assigned only to bots by default. For now, only one user can be notified
in one API request.

If the email flag is set in the API params, the notification is also
sent as an email, provided the user hasn't disabled email notifications
for the "api-triggered" category.

This feature is behind a feature flag. Set $wgEchoEnableApiEvents = true
to use.

Adapted from If0267a38be7d454e3d284d30f93c93a828288dd7.
Co-authored-by: TheresNoTime <starling-ctr@wikimedia.org>

Bug: T58362
Bug: T306211
Change-Id: I94642bff5dcb075cb9db862206d59c19edad9fd1
2024-05-04 17:43:39 +03:00
Cole White e4fd529dd6 configure main hook handler to pass StatsFactory service
Bug: T363590
Change-Id: Iadf0deeb8577a44554e66989ed432e119e6cbbe3
2024-05-04 08:10:41 +00:00
Umherirrender 96ef4cfd2d Migrate to IReadableDatabase::newSelectQueryBuilder
Also use expression builder to avoid raw sql

Bug: T312333
Change-Id: I6ce22de6637fccca8cf86a405bc023f268ff693b
2024-04-28 01:05:10 +02:00
Umherirrender 760cfad682 tests: Return FakeResultWrapper from mocked IReadableDatabase::select
To match the return type documentation of IReadableDatabase::select

Also fix a default value for IReadableDatabase::selectRowCount

Change-Id: I510bd261b64b5c2cef227c081a2fe34801f54121
2024-04-19 21:52:50 +02:00
Umherirrender 2feece8bad IReadableDatabase::select cannot return false
Remove check for false from IDatabase::select as this is not possible
A DBQueryError is thrown (documented since efda8cd3 / I056b7148)

Change-Id: I465a9158aa6430e7ff8a5a83fe55c5944315aa40
2024-04-18 22:53:15 +02:00
jenkins-bot 71ec391deb Merge "Migrate to IDatabase::newInsertQueryBuilder/newUpdateQueryBuilder" 2024-04-14 18:00:20 +00:00
Umherirrender aa41e1e292 Migrate to IDatabase::newInsertQueryBuilder/newUpdateQueryBuilder
UpdateQueryBuilder does not return a value,
removed the return value from the functions as well,
deprecated since 1.33

Change-Id: I3b934a5e6d5a53c07ec5233da00d9f53ba7bae92
2024-04-13 22:51:32 +02:00
Umherirrender d2eb46e7b9 Migrate to IDatabase::newDeleteQueryBuilder
Change-Id: I516c179df464be68352809873dbff44dc3c642f1
2024-04-12 22:45:45 +02:00
Fomafix 5595193eb3 Inject services into TitleLocalCache
Change-Id: Ib1259484436591dd30b29651ccca474c0ce16d13
2024-03-17 21:22:00 +00:00
Reedy 2b58f29d8c Fix casing of MediaWiki
Change-Id: If581a54ac1025bb13ff8fce5e8f64b92c71de986
2024-03-12 15:25:19 +00:00
Umherirrender d60c797629 build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: Ie03e1cdbf7f3a18c4e02e08fbd81c148f7da4d5a
2024-03-10 19:22:36 +01:00
Sergio Gimeno 152db8a06f Replace deprecated usage of wfGetDB
Bug: T330641
Change-Id: I863dc67e3196ea20c4f6145c5d3bb68b445b5195
2024-02-13 20:22:33 +01:00
Novem Linguae c71d826ede Remove $this->tablesUsed from PHPUnit tests
Deprecated in T342301 in v1.41. This is now tracked
automatically. The variable can be safely deleted.

Change-Id: I3864ee85e8b0ff74385eee88018a37f61927f5ef
2024-01-14 04:48:27 -08:00
jenkins-bot fd16e04f7d Merge "build: Update linters" 2023-12-20 23:09:30 +00:00
Umherirrender 9c94786dea tests: Use TestingAccessWrapper::newFromClass in DiscussionParserTest
Currently using ReflectionProperty::setValue(), which is deprecated for
static values in php8.3

Change-Id: If53b7ae9d58e8e5d6eb95f6fff07038b9c1bdd42
2023-12-13 20:43:18 +01:00
Umherirrender a0ca1d89c6 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: Iad87245bf8082193be72f7e482f29e9f1bad11fc
2023-12-11 16:39:00 +01:00
Ed Sanders 2f61c46cf0 build: Update linters
Change-Id: I234e460ce1d1887af17c90cb9536aea76e295ca8
2023-12-04 14:11:35 +00:00
gerritbot 2560aa4b7f Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: Ic3e56c6e2ec606bbecbd630d8ad96d111cab24d3
2023-11-29 15:34:02 +00:00
Daimona Eaytoy 164b3b9148 Update tests for PHPUnit 9.6
- Avoid withConsecutive()

Bug: T342110
Change-Id: I1c68e9b259039d58b468f25ed2e6fd0f73d70776
2023-11-21 23:55:06 +01:00
Fomafix 829003cabf Use $this->getServiceContainer() in maintenance and tests
Use
	$this->getServiceContainer()
instead of
	MediaWikiServices::getInstance()
in maintenance and tests.

Change-Id: I845e8f083b19da093166d6551683f2013eec7bb1
2023-11-09 20:18:48 +00:00
Siddharth VP 035f39d76c Use dependency injection in hooks
Removal of globals for reading config to be done in a follow-up patch

Change-Id: I8652ca67375ce2f2d79de93e0a3b75ac998131e0
2023-10-14 23:44:57 +05:30
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