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
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
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
Use mocks when possible, and add the test to the Database group
otherwise.
Also rename 2 test files to avoid a PHPUnit deprecation of file name not
matching class name.
Change-Id: I16b2392daf01f63511c82b4ed0e67a38e35ddbe1
This will essentially all be deleted after I55c18cf723a32f80b93a01dd0687e005162c4e93, but thats fine\
Bug: T343053
Change-Id: Ifb382af388cdc24dc1ecef105ec89c9129194c19
When calling editPage() with a string it converts it to a WikiPage each
time it is called. When edit a page only once that is okay,
but when adding more revision to the same page it is better to pass a
WikiPage instead to allow reuse of internal states of WikiPage to speed
up the tests
Change-Id: Iac4ef3a3838ba22cd98b944e3ac7f596d540b405
* Remove redundant file closure.
* Remove needless QUnit.newMwEnvironment() calls as the tested
methods don't alter mw.config or mw.messages. Slow, as per
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/912936/
Change-Id: I61bf03325d5067568d057ff2af6bf65f279a8a84
Test ServiceWiring.php using tests copied from CentralAuth. Because
phpunit does not support marking a file as covered, the ServiceWiring
file is ignored for code coverage as the tests should partly cover
the file.
Change-Id: I3ea5ae553d17e17680fcac4d92746fc7ce282eaa
- Don't manipulate $wgHooks directly, use setTemporaryHook.
- Avoid premature access to MediaWikiServices from data providers
- use overrideSettings instead of setMwGlobals
Needed-By: I0ebba9a29f81b0d86ad8fd84d478fb244f9e9c15
Change-Id: I52b9251793a5d559658fcf1e0d20f5a497e5fc43
Notably: any() is the default anyway. It doesn't really make the
tests more specific or better readable when we repeat it all the
time.
Change-Id: I56d201bfce454587b00015b7208f313dd8ed9624
fixes:
ContainmentSetTest::testCachedListInnerListIsOnlyCalledOnce
strtr(): Passing null to parameter #1 ($string) of type string is deprecated
Change-Id: I9bb916383eda1176a2d56c06770a60c28431dfda
Replaced WikiPage::newFromID with newFromTitle,
because a Title object exists and could be reused
Bug: T297688
Change-Id: Ide30f259477ed8e0b48df31f5a23cafeb38d7316
* Declare variables inline, as per the current code conventions.
* Convert ad-hoc cases objects into native QUnit.test.each().
This makes for shorter and cleaner code, as well as for more
detailed test reporting, and removes the need to manually construct
assertion messages based on test case prefix string etc.
* Start adopting ES5 Array.forEach in a few places where otherwise
ESLint would complain about variable name clashes.
* Future proof the test module names, by stripping the global variable
namespace that some classes still use, matching packageFiles convention
as used for NotificationBadge.js and its tests already, by specifying
only the bundle name and the exported class name. Note that the
QUnit UI does fuzzy matching so filtering works the same either
way, e.g. "echodmfilter" will match "ext.echo.dm - FilterModel".
Change-Id: I49858dd2c95d0869f2cd15693f05c38312a9f710