If the test expects the user to exist, it should use getTestSysop to
guarantee the account creation. Otherwise, use mocks or different
usernames to clarify that the username is not relevant to the test.
Change-Id: I87a27f01e1874af410e5d43e2e7fc3b10bb14eb8
Some non-database tests are currently accessing the database. Fixing
them means either avoiding the DB access if it's possible and makes
sense for the test, or adding the `Database` group otherwise. In
particular:
- Replace global/static functions with services in a couple places to
make testing easier.
- RevisionRendererTest needs to be in the Database group due to heavy
global state usage (including DB) by Parser
- ActionFactoryIntegrationTest and SpecialPageFatalTest should be in
the database group because they test many different classes, and some
of which may use the database in the tested methods.
- SpecialUserLogoutTest must be in the database group because of User.
- Some pager tests are using wfGetDB directly.
Change-Id: I96eb2acf9a2cbfd17e81225db2773d5e8e30260b
Since 9cc1cd3 a filterDeprecation() call exists to hide MediWiki
deprecations, let php deprecation show up
Depends-On: Id07a55743bdfe04022b7c96acb6c154c7fe33098
Change-Id: Ia51b00399c584671ccf5d9fb8dfed1e94e5d60f9
With PHPUnit 9, tests without @covers tags are considered risky and emit
warnings. Not having @covers is bad practice anyway, so use
@coversNothing instead to make the intention clear, and re-enable the
phpcs rule.
Also rewrite an assertion in ResourcesTest that was bothering me.
Bug: T243600
Change-Id: I6dd683f93b6b2faed5f107be2ca7860602277fbc
We cannot access MW services in a data provider, as MW will not have
bootstrapped by this point in plain PHPUnit. And we do not want to
bootstrap MW by the time a dataProvider is executing, because unit tests
should not need (nor be able to access) MW services.
Change-Id: I21a5993f91b8fbe3fa476a8244b8911cf81e1d5f
This reverts commit be7565e3e1.
Reason for revert: Needed for a revert of CentralAuth change I3baf207711.
Change-Id: I847086a8ea2be8931b9f3fc092467445c47644a0
This causes this test case to be run with sql_mode set to
STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY, instead of the default TRADITIONAL
set in DevelopmentSettings. Many database pages (such as those including
a pager) make database connections when loaded without parameters.
If this can be merged without problems it would let us un-revert
Ic2729428297162763a772e6a16549ded8de06c01 too.
Bug: T304762
Change-Id: I3bb424ddcbd7d3d6c03ad23d071a69a94b7f5749
This reverts commit f2de49b694.
Reason for revert: breaks CI for several other extensions.
Bug: T297020
Change-Id: I20061df89f4727431be84e52e5133fe50412d338
special page constructor should be cheap and
not infer global context on Special:SpecialPages
Depends-On: I6a3dd263dbe02111aea65a087ce69a5a191f63fc
Depends-On: I39dee5bd5064e319d7209e8f86da70bc5383a9bf
Depends-On: I75d3593de0233540710d69ba9a30631cb62fd262
Depends-On: Ifdc9e45d8c0dbcdf03a849a40b42f65b1cf1aa65
Change-Id: Ia3cbbf4971072c922f8cc137f81607a2d3bf61fc
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.
Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.
Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
Jenkins logs show that some of the cases are slow,
but its hard to tell what special page "data set #74"
corresponds to
Change-Id: I9b2a04b35c31bedd71fa575a6d7b9634f8282031
Sometimes the special page can’t be created – for example, the list of
registered pages could have changed between the data provider and the
test function, due to extensions conditionally registering their special
pages. Skip the test in this case instead of crashing.
Bug: T275661
Change-Id: I573967ac22ed3a596b4f80b76d395ac948f802e8
ActorNormalization needs to have separate wiring if we want to be able
to access it by name. This is needed to allow access to the service in
declarative wiring, e.g. via ObjectFactory specs.
As an aside, this changes SpecialPageFatalTest to not construct special
pages in a data provider. Accessing services in data providers should be
avoided. This change does not eliminate all such access, but reduces it
by deferring service lookups via ObjectFactory.
Change-Id: I5792cdcc0e5b0d1681f55dbe3e1f70c34a0cb775
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)
My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.
Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
This is specifically for fatal errors, so it's fine that some
queries encounter (non-fatal) errors. Surpress them for now,
so that we can safely re-enable enforcement for everything else.
Bug: T248191
Change-Id: I962ee2dbb0568cc869fda6fa7312edc45ba43215
SpecialPageFatalTest:testSpecialPageDoesNotFatal is one of the slowest
tests (specially running Special:Version) due to the fact that it needs
to translate so many message keys.
3206ms to run SpecialPageFatalTest:testSpecialPageDoesNotFatal with data set "Version"
Running with lang=qqx would ensure that the special doesn't fatal but also avoid
unnecessary message translations
Change-Id: I8ff715ac539e93915c98f7209523df1b3ea3a7e8
@covers does not make any sense for structure tests, which either
do not cover any PHP lines (they test things like configuration or
messages), or cover lines which cannot be determined at the time
of writing the tests (e.g. they cover all classes implementing a
certain interface). Requiring @coversNothing to be manually added
for all of them is a waste of developer time.
tests/phpunit/suite.xml has forceCoversAnnotation=true so removing
the annotations will not change test coverage, these files will
still be skipped.
Change-Id: I27cb58e92341b9b1a76f109701f5bc843adbaa9b
Deprecation notice from SpecialPageFatalTest is the most merge blocker
since merge of I8fb26380724b6b12bf08458dbff2e00b759d219b
Deprecation can occur at any time and than break many extensions to
merge, even there are still working.
Ignore deprecation as before, but keep the error and notices
Change-Id: Idcbc38b662c569fbe8e778a6b1ab815db332dc08
When the php notice is converted to exception,
it is also from type Exception and currently ignored.
Catch the special phpunit exception type separated and rethrow.
This changed is in a structure test and can break other exceptions.
Change-Id: I8fb26380724b6b12bf08458dbff2e00b759d219b
LessFileCompilationTest is checking less files for valid syntax
doc test is checking xml file for valid syntax
MediaWikiTest is testing a complex situation with many functions involved
SideBarTest is self checking, needs no coverage
structure tests not covers functions, there are covers global structures
Change-Id: I3ac65db561cae0be8418aa9c830e7a9f46ad11fe
Trying to avoid resetting services introduces a lot of complexity and
several bugs. We were doing a reset for 70% of @group Database tests
anyway.
Instead:
* Reset services at the start of MediaWikiTestCase::run().
* Capture the actual original service container instead of making a
special shared service container.
* The test-isolated local service container can now only be initialised
non-statically. Revert the recent conversion of overrideMwServices()
to static.
* Store a reference to the local service container in the test case
object. In MediaWikiTestCase, always use the original or local service
container directly, to avoid confusion about which one is active at
the time.
* Remove a lot of unnecessary teardown
* Always call ServiceContainer::destroy() before forceGlobalInstance()
since the memory is not otherwise freed.
Change-Id: I4a17c1c7ec92c14e3bc471f0216473ebe19477b9
Calling SpecialPageFactory methods statically is now soft-deprecated.
SpecialPageFactory::resetList() is a no-op, and I changed tests
in core to use overrideMwServices() instead.
Methods that fell back to $wgUser now require a User object being passed.
Depends-On: Ie1f80315871085b9fd4763a265b588849d94414d
Change-Id: Id8a92d57743f790b7d8c377c033cef38d1bb24de
This test makes sure that special pages do not fatal
in their most basic form (anon user viewing the page).
Depends-On: I3a9f5b315eb114cb12ea4071f8da9079f797fcf6
Change-Id: Ic675e92d8dd8f11fa67914d2ce1dc00a379106ca