ParserOptions store the result of ParserOptionsRegister
hook execution in a static cache. If we register a lazy
option, which depends on user options and use OptionsLookup,
tests break because a lookup from a destroyed service container
ends up being reused between tests.
The reset was added to resetLegacyGlobals because 1) it's
called at all the right times 2) this static cache is legacy,
when we have a factory service for ParserOptions, this will
not be needed anymore.
Change-Id: I9e820045443be1df2c89e1ed4b56f0d55662c486
Removing this deprecated cache allows LanguageFactory
to start using MapCacheLRU instead of implementing
LRU semantics manually.
Change-Id: I8093067fb6f51110351b8592fcbcfa7559d942ee
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.
Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
AuthManager has been converted to a service in 1.35.
AuthManager::$instance is only used in AuthManager::resetCache(),
where it is set to null.
This patch also removes AuthManager::resetCache() because with
removing AuthManager::$instance AuthManager::resetCache() has no
longer any effect.
Change-Id: I8b27f9a2d0d3f7acec6b93f64f9c256084990026
This option has been dysfunctional since at least MW 1.32: with
the option set, no tables would be cloned, and all tests trying to
access the database would fail.
Apparently the option was originally introduced to improve speed
when testing against a Oracle database backend in
5933586266.
Since nobody complained about the option being broken,
and we no longer support Oracle, it should just be removed.
Bug: T283146
Change-Id: I7d7f10b2c863ab92279c7817893086ad50e6ac4d
Use was removed in I7dc3fe90385c8066b89a5e06c55f5455edfbb4ca
when the logic that was using it was moved to MediaWikiTestCaseTrait
Change-Id: I3be7fdb0ad3e76d0f0bff713c21cb9216b77ee20
This replaces JobQueueGroup::singleton and ::destroySingletons.
A JobQueueGroup service has been added to serve as convenience
getter.
Bug: T277648
Change-Id: Ic8709119773ab788a07531193dc65d418536eda2
Have MySQL emulate PostgreSQL's standards-compliant GROUP BY
nitpicking, so that MySQL developers can tell whether queries would fail
on PostgreSQL.
Bug: T281329
Change-Id: Ia9e6c6ad3286dd37f7efb55045e8556d85791c37
JobRunner catches all exceptions and hides them in the status array,
meaning that it is not obvious when a job fails during a test case.
So, introduce MediaWikiIntegrationTestCase::runJobs(), which runs jobs
and asserts various things about the returned status array.
Depends-On: I4f4790c5d16a0767790eeff202e0be8fcdaeda93
Depends-On: I118f9e3f8950fd82d7b02baed6705b29fd6ab7d5
Change-Id: I63603aa158f77df4b40add096cb248f3b24979f4
This logic is not needed to run on every PHP process and was making
it difficult to run offline maintenance scripts without additional
complexity based on Maintenance::getDbType and DB_NONE.
Instead of skipping this only for DB_NONE, and establishing a pattern
that may spread to other ad-hoc places throughout the codebase, instead
remove this entirely from the eager set up code for all PHP processes
and move it to the service wiring and dependency injection.
That way, it naturally doesn't happen until and unless the DB service
is actually called upon. Scripts and entry point that need to disable
the DB service, can continue to use
MediaWikiServices::disableStorageBackend.
== Impact on SiteStatsUpdate ==
With wgCommandLineMode no longer being read at run-time from a global,
but in service wiring, this means SiteStatsUpdateTest can't change
the behaviour between CLI-like and Web-like, unless it e.g. resets
the 'DBLoadBalancerFactory' service first. Unfortunately, while most
any reset is supported, a reset of the 'DBLoadBalancerFactory' would
be unsupported as that would lose the temporary db clone context and
such, bringing us to either the developer's live db, or a broken set
up altogether. If there is a strong need for toggling oppertunistic
updates off and on at run-time, this could be supported in the
DeferredUpdates class perhaps, but we already have numerous methods
there (incl db begin/commit being a good proxy already), which this
test already used, so for now I've just removed the extra assertion
for this as it wasn't essential to that test.
Bug: T228895
Bug: T238436
Change-Id: Icf29bc484c155f52b6d8f61e5902233a15ba0c6d
Set functions to final.
This avoids that the function is overwritten without parent call
Follows-up I9d4771c28160356ff58.
Change-Id: I40cde489a892b06284692ecbbef14e650afe7c9e
Discovered in another patch that while integration
tests automatically reset fake timestamps afterwards,
unit tests don't. Add a shared method to MediaWikiTestCaseTrait
to reset for both integration tests and unit tests
Do the same for TypeDefTestCase
Change-Id: I677aec4e60894053fc554f2e13b069fb599858f2
No integration needed, though it did rely on
checkPHPExtension which was only available in
MediaWikiIntegrationTestCase, moved to
MediaWikiTestCaseTrait
Also put under /includes/historyblob/ to match covered class
Change-Id: I0bfe3e44bd45535c18f5ee2534430330586a1c4c
Without this, expectDeprecation() will not work if the same
deprecation is emitted in more than one test in the same test suite.
Change-Id: I850a072cc61437d1ab33af082ee99534bc6deee6
Refactor the database setup code to share more code between
ParserTestRunner and MediaWikiIntegrationTestCase. Made
`::setupAllTestDBs` static so it can be reused from
ParserTestRunner.
Made ParserTestRunner::addArticle more like
MediaWikiIntegrationTestCase::addCoreDBData(). Some additional
refactoring work could be done here in the future to share more code.
After the refactoring the ParserTestTables hook is no longer necessary
and so has been (soft) deprecated. MediaWikiIntegrationTestCase
clones all database tables, so ParserTestRunner no longer needs to ask
extensions for a list of specific tables it should clone. Cleaning up
the handful of extensions which define this hook will be left to a
future patch set.
Change-Id: I5124789fac333a664b73b4b4a1e801ecc0a618ca
Also fix two places where we were using `$this->` in a corner case.
Using `static::` lets subclasses override these method definitions,
at least in theory.
Change-Id: I76a6d10ce463a5bc79e14051a31f469668924494
Deprecated since 1.35, not compatible with PHPUnit 8. This could've
happened earlier, but here we go.
Unused in known repos (except for the sniff looking for this usage):
https://codesearch.wmcloud.org/search/?q=assertType%5C(&i=nope&files=php&repos=
Bug: T192167
Change-Id: I479cf71d0941c35096d21686077b4d1cbc4f898d
Some User methods fail if they are called before $wgRequest is
set. But according to the Setup.php comment, it is only set for b/c.
The global request object can be lazy-initialised at any time.
This is sufficient to avoid T263911 (loss/obfuscation of the $wgServer
error message).
In tests, try to keep $wgRequest and RequestContext::$request in sync.
Introduce MediaWikiIntegrationTestCase::setRequest() which sets both at
once, and use that instead of setMwGlobals() or direct assignment.
BlockManagerTest was accidentally exploiting the fact that the global
context request and $wgRequest were separate objects. Making them the
same causes session cookies to appear in the response, breaking the
cookie counts. Use a new response for the test.
Bug: T263911
Bug: T245940
Change-Id: I2be99f7251a837bc6b62be0b152038157dec10f2
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.
Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.
Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
The editPage() convenience function in MediaWikiIntegrationtestCase
should optionally accept a WikiPage instance as a parameter. This
allows edits to be made conveniently, without any WikiPage instance
held by the caller going out of sync.
Change-Id: I68ad6df5f6dc357658fe112957bea8b11cf2471e
This reverts commit c17ddfd786.
This time, also: Trying to get mock http to work in parser test
Bug: T262443
Change-Id: Id708cdfa3d3c27f30543c6bf212df96e6b0a69e1
Tests should not make real HTTP requests. Mock out the
HTTPRequestFactory service to prevent this.
Bug: T262443
Depends-On: I63bfd54c3de55d678e8b862b85c0adfb5fc94d91
Change-Id: I1702c11928f8760bb41b41f4c7c04d7af03f62e2
This is causing problems for Parsoid CI, as parser tests fail when
phpunit runs the tests at a different point than they are run in
core's CI due to the side-effects of content-language changes made in
other phpunit tests. (For example, phpunit runs all extension tests
after core tests, so the same parsertest can pass if included in core
and then fail when included in an extension.)
SpecialPageFactory::$aliases has a dependency on the current content
language, with no way to reset it other than to recreate the
SpecialPageFactory.
Change-Id: I278580ed5cf2c85403cbaf601f8af4753e14a9d0