Commit graph

91 commits

Author SHA1 Message Date
Umherirrender
b32a3d6dfd tests: Use content language in DefaultPreferencesFactoryTest
Bug: T343771
Change-Id: I2d46db4be6e967ee5e7764c6df62d2214fe08683
2024-07-20 21:48:18 +02:00
Func
4e6158a6fb Use constants provided by MainConfigNames for config names
Change-Id: I2f29ea8227da64b79b70fcce3decb6e34ea8da5b
2024-05-18 01:26:46 +08:00
DannyS712
ee75e1c6f9 Tests: remove a bunch of DummyServicesTrait-related comments
Not sure why I added these, it should be clear from the method names

Change-Id: Ie49881e6f31fad52bb65b0d2ac3e9379dbb7bfc5
2024-05-10 04:07:59 +00:00
Umherirrender
f3524224f0 build: Fix line indents
Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of
arrays for parameters is wrong

Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
2024-03-11 00:14:16 +01:00
Derick Alangi
64d02c830f
preferences: Avoid injecting entire config object, use ServiceOptions
We're already constructing service options with the list of options the
service needs. Let's stick to the light-weight version and avoid injecting
the entire MainConfig object just to get 2 settings when we can just list
it them in CONSTRUCTOR_OPTIONS.

Change-Id: I0612ca1c129c55664f29e178959c017d849eb218
2024-02-19 15:30:26 +03:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Reedy
e94e265a93 tests: Add Tests to PHP namespacing
Change-Id: I849268172751d50292e93aa75abe8094873f56bc
2024-02-16 19:10:11 +00:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Daimona Eaytoy
c8e2f99211 Update tests for PHPUnit 9.6 (part 2)
- Avoid withConsecutive()

Bug: T342110
Change-Id: Iedda49765cbceeb10ccd72d0248f3cda9241da1e
2024-01-17 18:16:38 +01:00
Func
36478be22e tests: Run the UserGetDefaultOptions hook for preferences tests
The test error is reproducible when $wgAllowHTMLEmail is set to true.

Bug: T341931
Change-Id: Ic35c35f2c2ec75a3f8c46e50ad7ec2f6867d5b0c
2024-01-10 04:18:23 +08:00
Martin Urbanec
29af4dd074 Move user options related classes into its own namespace
There are a couple of user options related classes already,
and the T321527 work on dynamic defaults is going to add
even more. Let's move them into a separate namespace
to make core a bit more organized.

Old name is kept as an alias for compatibility purposes.

Bug: T321527
Bug: T352284
Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
2023-11-29 13:27:13 +01:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
3851805f64 Namespace remaining User-related classes under \MediaWiki\User
Bug: T166010
Change-Id: Ibda1e8be0f23c6262a32b607f8260cad36f188fc
2023-09-20 09:12:08 +01:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
a8a6cfd966 Namespace NamespaceInfo under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
2023-09-19 05:17:04 +00:00
Umherirrender
1796dc225c preferences: Pass ParserFactory to DefaultPreferencesFactory
Bug: T343070
Change-Id: I10307ba3b76bc7b86617dbe2c4da6d745a73fdbe
2023-08-14 17:05:56 +00:00
Daimona Eaytoy
59b93e9e4f Avoid DB access in non-database tests
Mock the needed dependencies to avoid database access when possible, and
add the test to the Database group otherwise.

Bug: T155147
Change-Id: Ic5c39ab35ab4d993721713285180f072497a5a40
2023-08-06 22:57:48 +00:00
Daimona Eaytoy
2a0de02aab phpunit: Avoid TestUser in non-database tests
TestUser creates the user and therefore needs the database. Avoid using
it in non-database tests.

Add ApiQueryBlockInfoTraitTest to the Database group because it needs
the database.

Add DeleteUserEmailTest to the Database group because since 3bedffa8
the default user is not created any more in non-database tests

Change-Id: Iff438964dde47a47a2fa4a314d55010bd8c7fee5
2023-07-29 14:26:50 +00:00
Ammarpad
06816e387e Tests: Fix config value override
DefaultPreferencesFactory uses ServiceOptions which does not use
live config values so using mock config is not actually working here

Use ::overrideConfigValue() to truly force the test config value

Change-Id: I4c8f57732ce54021fedb00c0d11835855a851b97
2023-07-26 15:28:53 +01:00
thiemowmde
8a9dd67139 Avoid calling overrideConfigValue() multiple times
Same as I7a82951.

overrideConfigValue() and overrideConfigValues() both call
setMwGlobals(), which calls resetServices(). This is surprisingly
expensive. It's much better to call it once with an array.

Change-Id: I4ff2f6b902b1a1e0b554ce6fc76f3b612f703fae
2023-07-20 14:59:42 +02:00
Ammarpad
f6550903da Tests: Do not rely on local value for $wgEmailAuthentication
Test should not fail when $wgEmailAuthentication is locally disabled

Change-Id: I1854d45ecaa7b42151d47e54b2b84049c43856fa
2023-07-11 14:43:48 +01:00
daniel
c4033734db HookContainer: deprecate old hook handler formats
This reduces the acceptable forms for hook handlers to three things:
* a callable (in the form of a string, an array, or a closure)
* an object, which is expected to have a public "on" method that
  matches the hook name.
* an array containing an object spec in the "handler" key, for use
  with ExtensionRegistry.

All other forms will trigger a deprecation warning.

Bug: T339167
Depends-On: I980f2d45e6bb8c6a04058e68c758f71bbcf709de
Depends-On: Ieae405f70caa01d84602583cc214b0ee3fadc796
Depends-On: If15df4b598c02ed9bda5eea0ae89a16ebbf4f2e2
Depends-On: Id70276fa1e1821bd400dc0ae5cea722a21d524d5
Change-Id: I83bc81d1b3033c38b9313884a9c70a187fdde227
2023-06-21 11:40:10 +00:00
Umherirrender
580439e604 tests: Use MainConfigNames consts to refer config names
PasswordSalt was dropped in 2e909bcb

Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
2023-06-19 20:21:08 +00:00
Daimona Eaytoy
7340a7fdf9 Replace usages of deprecated UserGroupMembership::getLink()
Bug: T183174
Change-Id: I34f40bd88404cfb7826dfd4d0ef3d662f6091c65
2023-05-20 21:21:19 +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
thiemowmde
66b0d4fc45 Replace Config mocks with trivial HashConfig instances
The Hashconfig class is as trivial as it can be. No need to mock it
in these situations.

Change-Id: I09cd46b0ee2c84927f88cf4e40923b643100e528
2023-03-01 08:15:28 +01:00
daniel
8c1c1ae35a Enable pig-latin variant for testing
Having pig-latin enabled per default in dev environments is convenient
for manual testing. More importantly, it will allow us to write
end-to-end tests for variant conversion.

Depends-On: I9dc2f743ac487b0f7cfb667150c0f6950d5e7fce
Depends-On: I85b66c85be3959d48a048733af17197bc4cf70af
Change-Id: Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38
2022-11-08 17:45:51 +05:30
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Matthias Mullie
ea6c1ceebb Add preference to control Special:Search thumbnails
Bug: T320337
Change-Id: I828dcd3679a4869b3b58b05d7cdca6c9f8a45d3e
2022-10-17 13:48:12 +02:00
Roman Stolar
5f53f2a8a2 Replace usage of User::getOption
Update tests

Bug: T296083
Change-Id: Id209abd408a1fdecb0a39c0910b12d34458ed458
2022-08-19 21:21:36 +02:00
TheSandDoctor
da38639658 Remove deprecated $wgParser
$wgParser, deprecated in 1.32, has been removed.

Bug: T160811
Change-Id: Iaf09d3e158e1fee8c0f541695b6d9b4233033c81
2022-08-03 14:40:16 +02:00
Derick Alangi
5e8cd2c838
Migrate from setMwGlobals() to overrideConfigValue(s)
Change-Id: I3f167d0e7d59a5aa091c3095a7d96c889d6e7e78
2022-08-02 10:14:10 +01:00
Brian Wolff
ac5f8a793c Mock UserOptionsManager::getOption for php8.1
php8.1 is more strict where we can return nulls

Bug: T313663
Change-Id: I079ec2cc732d44710d2ba001f803d96134f0d6c0
2022-07-27 21:26:48 -07:00
Brian Wolff
04238e44e5 [php8.1] mock User::getTitleKey() in DeaultPreferencesFactoryTest
php8.1 doesn't appreciate the default behaviour of returning null.

Bug: T313663
Change-Id: I2cdfe385d094427c545695af57657c3a5db2ce81
2022-07-26 15:37:29 +00:00
Thiemo Kreuz
61ae7504df Replace trivial usa of mock builder with createMock() shortcut
createMock() does the same, but is much easier to read.

A small difference is that some of the replacements made in this
patch didn't use disableOriginalConstructor() before. In case this
was relevant we should see the respective test fail. If not we can
save some CPU cycles and skip these constructors.

Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
2022-07-15 16:43:48 +00:00
Tim Starling
13c1839735 Fix SignatureValidatorFactory circular dependency
Parser is using the service container to get a SignatureValidator
because, as noted in Gerrit comments on the relevant commit, there is a
circular dependency Parser -> SignatureValidatorFactory -> Parser.

So, have SignatureValidatorFactory::__construct() take a closure which
returns a Parser, instead of an actual Parser or ParserFactory.

Change-Id: I7bf4660f84ec8c8fb1d5b3b8581fe5d82bc3156e
2022-04-13 12:38:00 +10:00
Func
983b16d092 phpunit: Fallback to global default user options
The real option manager would do such fallback, this behavior should
be kept in tests.
(Depends-On I814050cfa86ec1e86291d380843eb319fddc924a)

Bug: T297082
Change-Id: I55f7d1e17bde904f2245b31df2df853cf0ca803f
2022-03-30 13:17:10 +00:00
Alan Thomas
f003b125ba Allow the user to set a default number of search results
Bug: T215716
Change-Id: I2b355f7830b24f7353a7e7f9e102d5be77b534d6
2022-02-20 22:09:47 +11:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
bwang
0dcbe84184 Update skin ordering to prioritize skins set through a new config
Bug: T298933
Change-Id: Ic957421617b519bd8160be475ac538b0944a8da9
2022-01-26 23:59:41 +00:00
Kosta Harlan
67e88c00cc phpunit: Mock session object for user in DefaultPreferencesFactoryTest
Depends-On: I6c7216611ce5ca65eda589a1a07014c9ce007957
Bug: T297082
Change-Id: Ie1ad9cf71129bcadbe1de6cd82f2662998941ba1
2021-12-06 08:44:50 -05: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
DannyS712
2915e0bbbf DefaultPreferencesFactory: inject and use UserOptionsManager
Inject a UserOptionsManager instead of UserOptionsLookup, and
update deprecated calls to user options methods

Bug: T277600
Bug: T277818
Change-Id: Ifdf491c3fd6b5b16246f33012f1db21f2cbc1f3e
2021-06-17 17:27:40 -07:00
DannyS712
fcad1b9e44 DefaultPreferencesFactory: inject all services needed
Inject LanguageConverterFactory, Parser, and SkinFactory,
plus remove use of UserOptionsLookup from MediaWikiServices
in favor of the existing injected one

Change-Id: Id8635a7a982f84828f3c0ba71f8446dd3d666a25
2021-06-04 23:51:59 +00:00
DannyS712
7c59cb3a8a DefaultPreferencesFactory: inject a UserGroupManager
Has a fallback in case one is not provided, so as to not
break the GlobalPreferences extension

Includes fixing the expectations in the tests
for the underlying code in testUserGroupMemberships

Change-Id: Ia539e48c305787f7e2a9a3a0b42891b7a8e2912b
2021-06-02 19:06:27 +00:00
jenkins-bot
c60ccf4e6d Merge "preferences: Move complex creation of infos for usergroups into closure" 2021-05-27 19:52:04 +00:00
DannyS712
779bd0aae8 Migrate DefaultPreferencesFactory to authority
Use authority methods instead of the injected PermissionManager;
not removing the PermissionManager yet since it would break
the GlobalPreferencesFactory which extends the class

Change-Id: Ia804fa7e536d0746f49f51792a48af9f4834183c
2021-05-26 06:39:45 +00:00
Umherirrender
215431bfd4 preferences: Move complex creation of infos for usergroups into closure
The HTMLInfoField allows the default part to be a closure.
This delays the message parse until the messages are needed on a gui.
This avoids the message parse on save or api calls and hopefully makes
that faster.

The message prefs-memberingroups is now parsed as all the other label
messages. This is another fix as done for T142882 / 116063f

Bug: T58633
Change-Id: I860501fe3df1ee330460f04ffe8493dd16421c8d
2021-05-25 18:17:37 +02:00