This change implements two things that can be combined to allow
the usage of services like the TitleFactory in subclasses of
MediaWikiUnitTestCase:
1) This adds getServiceContainer() to the MediaWikiUnitTestCase base
class, to mirror the method of the same name on
MediaWikiIntegrationtest case, along with a a setService() method
for defining service objects for use in tests.
2) This adds makeMockTitleFactory() to the MockTitleTrait, to allow
tests to esaily define the TitleFactory service.
Making services available through a service container primarily
benefits code that relies on ObjectFactory, like REST handlers.
Needed-By: Iac113a9e766e38b2d19ae99b7e448548a515469e
Change-Id: Ida6c37c7133b9e3887268025daf6e5b7c1340e52
This moves a code out of file scope into classes to make it
testable. The code is left in the same structure as it was before,
global functions have been converted into methods on the new
ThumbnailEntryPoint and Thumbnail404EntryPoint classes.
This test introduces comprehensive phpunit tests covering all functional
code paths in ThumbnailEntryPoint. This is intended to support
refactoring of this code.
Change-Id: I459abc7b11d0ab4ee682a863c9525a945048296f
* Inject from ServiceWiring via PoolCounterFactory.
* In production we use PoolCounterClient (which is backed by
our poolcounterd service), we also offer PoolCounterRedis for
third parties. Replace the local logger in the Redis variant in
favour of the built-in one.
* Update PoolCounterWork to adopt this as well. Expose it via getter
to here, so that DI works all the way, including for the existing
test.
Bug: T358901
Change-Id: I5413825a0172b186d58e85bbc3cc93697b174c27
1) Introduce EntryPointEnvironment which wraps functions that interact
with the PHP runtime, so they can be mocked for testing.
2) Allow server info fields to be overwritten in FauxRequest.
3) Make MediaWikiEntryPoint use WebResponse to set headers
Bug: T354216
Change-Id: Ic21950c956de5d2b5a7dd66a1e2de58f807cfd9f
Two of the classes in this directory have already namespaced to
MediaWiki\PoolCounter.
Bug: T353458
Change-Id: Ie41f8d935f7623bb40040a5eb78f99c6d7b7b75e
Changes to the use statements done automatically via script
Addition of missing use statements and changes to docs done manually
Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
Follows-up Ie420f2b42ee7d. Not yet used, and in line with T326274
would ideally not need to be used.
Bug: T326274
Change-Id: Iddd5c2245bcd4215e2ed86ac64d186e8cc9fb095
Traditionally we tell people to avoid mocking the database, and we
haven't make a centralized way to do it. This has just led to it being
done poorly and verbosely in a lot of different ways.
So, add a MockDatabase class.
Change-Id: Ie420f2b42ee7d047378221c519845f7261c20c28
Why:
Temporary accounts (introduced as part of IP Masking)
are supposed to expire 1 year after their registration.
Automatic account expiration can be done via a maintenance
script, which would be periodically executed via cron / systemd.
Make it possible for extensions to provide their own logic
for generating a list of temporary accounts to invalidate.
This is used in CentralAuth to base registration timestamp
on the global registration timestamp.
The default behavior is "temporary accounts do not expire",
given the feature requires a maintenance script to run
periodically, which will not be the case on third party
instances.
What:
* Add `expireAfterDays` to $wgAutoCreateTempUser, controlling
how many days temporary accounts have.
* Add UserSelectQueryBuilder::whereRegisteredTimestamp(),
filtering accounts based on user_registration.
* Add ExpireTemporaryAccounts maintenance script, which is
@stable to extend.
Bug: T344695
Change-Id: If17bf84ee6620c8eb784b7d835682ad5e7afdfcc
Remove the 'user' option from the documentation and defaults. It has
been ignored since a3b4881f6f (2021, 1.37).
Fix tests which pass unknown constructor options. I found these by
temporarily patching the constructor to throw when an unknown option is
given.
Change-Id: I95cb2a38a5688d83c90ad501786f6d6bb02765ba
This trait provides a robust way for tests to simulate user blocks.
Developed as an alternative approach to I7fc457eff88.
Change-Id: Ia5d813fcbdd77b94dbbc730ca4639d6efd2148a8
* Add getMessages method to BlockErrorFormatter that will get
error messages for all the applicable blocks.
* Call getMessages from PermissionManager, UserAuthority and
EditPage.
* ApiBase and UserBlockedError still call getMessage since
they work with a single message.
Bug: T344463
Change-Id: If240562dd25435d9c6c824dd595d58bb8672de2b
I worked around this with a custom mock for the moment, but would
like to use the upstream trait in the future.
Change-Id: Idf28d905f9fd01c24f29ad6a60419bfb4896704c
Why:
- MockAuthorityTrait doesn't allow setting up a mock with rate limiter,
but user authority test has a bunch of code that could be used for
that purpose
What:
- Copy the private helper methods from UserAuthorityTest into MockAuthorityTrait
Change-Id: I2114056e1c0447080828485e229d82290baf3b24
That would remove the need for passing around LB.
ReadOnlyMode code needs a lot of clean up. In follow up patches, I want
to inject WAN and possibly APCu to this and remove that from LB itself
to decouple LB/LBF from BagOStuff.
In even later patches, I want LB/LBF to set the ReadOnly in the service
instead and reverse the coupling.
Bug: T343917
Change-Id: Ibe7f80292d911fc8953e59f74264c499ab1700d0
As far as I can tell, there are no other CommentStoreBase subclasses
anywhere, and everything outside the tests calls CommentStore with
hardcoded MIGRATION_NEW, so all the support for other migration stages
has been dead code for a while now. Let’s remove it to make the code
simpler and less confusing.
Bug: T343558
Change-Id: I411967bd19979de47463aa93891cdc55baf89653
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.
Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
If a username matches $wgAutoCreateTempUser['reservedPattern'], but the
username is not a valid temp user, return false from
UserNameUtils::isUsable().
This makes reserved patterns analogous to $wgReservedUsernames, and
provides a simple way to reject central sessions for temp users on wikis
where temp users are disabled.
Bug: T342475
Change-Id: I1d7f843e71e605fccf3de93fd145ff43e396619f
Extensions may implement hooks defined by other extensions.
When the other extension is not present, the base class or interface of
the hook handler may also not be present. In that case, we should still
allow the handler to be registered. This is harmless, since the hook
will never fire if the extension that defines it is not loaded.
Bug: T339834
Change-Id: Id975370dececcb09ae5d00e6f68da57dc22fb267
Message:inContentLanguage() changes the language of the message to the
ContentLanguage of the current wiki. But for tests we want to keep it as
qqx and also not access any Services/DB.
Change-Id: Ic1d8b39b053fb0f6050bd7cbdfe7b140dd423659
Needed-By: I6dbb683d755b1a4eed6f0b158b26185cf11dbbde
The service was previously accessing the global ExtensionRegistry
singleton, making it lose its statelessness. Dependencies should always
be injected, so add constructor parameters for that.
Simplify tests accordingly.
Change-Id: Iae375a81cab411fab607cba0addb2088131b3c81
I dug into a particular profile via KCachegrind (specifically the
profile for DirectParsoidClientTest in VisualEditor) and found this
surprising bottleneck. Let's say a test uses a data provider to test
a particular piece of code with 5 different languages. And then
another piece of code with 5 languages. And so on. Because the cache
can only hold 4 languages there will never be a successfull cache
hit.
The items in the cache are something like 1 or 2 megabytes each. It
should be fine to hold 16 of them in memory. Possibly even more. The
sweet spot in my example was 10. This is when the runtime of
DirectParsoidClientTest gets suddenly cut in half.
Bug: T225730
Change-Id: Ie04f338ee8a59f08be50947d794626ed52d793bc
This was a temporary flag to allow setting the migration stage for a
comment migration with a temp table.
Since the rev_comment_id migration is done, this is no longer needed.
Dropping the compatibility code for temp tables will be done in
follow-ups.
Bug: T299954
Change-Id: I290a74f27b05cd7e062dda78766911ffe3053d08