Add a HookRegistry interface and two concrete implementations,
representing HookContainer's view of its environment. This simplifies
creation of a HookContainer for testing.
Add MediaWikiTestCaseTrait::createHookContainer() which can be used
in most of the places that were previously creating mock hook
containers. It can also replace setTemporaryHook() in some cases.
Change-Id: I9ce15591dc40b3d717c203fa973141aa45a2500c
This existed on MediaWikiIntegrationTestCase, but not on
MediaWikiUnitTestCase. As a result of that, I spent about four
days tracking down a dangling AtEase::suppressWarnings with
missing AtEase::restoreWarnings (as part of Ib6758d724c).
Move it to the common MediaWikiTestCaseTrait instead so that we
get it on unit/ as well.
Example:
> There was 1 failure:
>
> 1) Pbkdf2PasswordTest::testCryptThrows
> PHP error_reporting setting found dirty.
> Did you forget AtEase::restoreWarnings?
Change-Id: I7dc3fe90385c8066b89a5e06c55f5455edfbb4ca
* Split MWDebug::sendRawDeprecated() from MWDebug::deprecated(). The new
function can be used to send arbitrary messages to the deprecation
log, rather than being constrained by the fixed format of
MWDebug::deprecated().
* Split formatCallerDescription() from sendMessage() to allow the caller
of sendRawDeprecated() to do its own caller formatting.
* Use the new function in MWLBFactory::logDeprecation()
* In tests, replace the ugly implementation of hideDeprecated() with one
that works by setting a list of regexes to filter. hideDeprecated()
now filters deprecation warnings that are a string match to the
supplied function. filterDeprecated() can be used to filter a regex,
and is intended to be used to filter warnings sent via
sendRawDeprecated(). The filter list is reset at the start of each
test, instead of leaking across tests as before.
Change-Id: I0d0df86db2e61cdd1769426bfa7bad4c2ae5e977
- add MockObject as a return type for createNoOpMock. Technically
object and object|MockObject are the same but this is enough to
prevent some IDE warnings about incompatible types (and to guide
IDE autocomplete although there is probably not much use for that
in a no-op mock).
- fix a legacy classname alias which modern PHPUnit does not provide
anymore
Change-Id: I6445bce2dd7a4bf97ad2374ab2dac566b3d73546
assertArrayEquals is a generic assertion that does not have anything
to do with integration testing, and is quite useful for isolated
testing of classes which return unordered sets.
Change-Id: I45af77402a1bc922579aff14b21874ec8680e765
These appear to be unused. Moreover, their behavior doesn't match their
documentation. getDefault() claims to return NullLockManager if no lock
manager could be found, but really returns it if there's no lock manager
named 'default'. getAny() claims to throw if no lock manager can be
found, but actually throws if no lock manager is named 'default' or
'fsLockManager'. The behavior can be easily replicated by just using
get() yourself and catching any exception.
Bug: T234227
Change-Id: Iad083847f45d6e017a3f7dbfece1f9c155c5efd6
709773ab57 introduced this method, but its implementation
does not permit calls to __destruct. PHP documentation on destructors
says that they'll be called unconditionally, which makes using the
mock created with this method unusable for classes that implement
__destruct.
Bug: T231656
Change-Id: Icb4f978c78e726401d75627128c9c76f6f9afc87
This is just a shortcut for a commonly-used pattern, when you want to
create a mock that's never supposed to have methods called.
Change-Id: Ia7267e3d3108c1ff94485f7e44bf409808a762be
I think this probably shouldn't be directly in the MediaWiki namespace,
but I don't know where is a better place to put it.
In order to avoid gratuitous use of TitleFormatter, I changed the cache
format -- the old implementation used getPrefixedDBkey() and I switched
to an ns/dbkey pair. I also changed the cache keys to use SHA1 instead
of MD5, by Daniel's request.
The previous implementation cached the parsed blacklist for one minute
without invalidation, so it could return slightly stale results, but it
didn't retrieve the bad image list message on a cache hit. The new
implementation unconditionally retrieves the bad image list message, but
uses a hash of it in the cache key and caches for one day. The new
behavior happens to be more cleanly implementable in a service.
Bug: T200882
Bug: T139216
Change-Id: I69fed1b1f3cfc1aa149e0739780e67f6de01609d