Make DBConnRef enforce the DB domain selected during its lifetime
and allow more nested and successive use of the same connection handle
via DBConnRef. This can avoid extra connections in some cases where
getConnection()/getConnectionRef() is used.
Also:
* Reduce the number of connection pools arrays from six to two
* Merge getLocalConnection()/getForeignConnection() into one method
* Expand various related code comments
Since LoadBalancer::getReadOnlyReason() no longer user the local domain
but rather DOMAIN_ANY, it should not result in "USE" errors if the local
domain does not have a database on the server.
This version of the patch removes the unused reuseConnectionInternal()
method (the method was previously added back to the patch by mistake).
Bug: T226595
Change-Id: I62502f4de4f86a54f25be1699c4d1a1c1baee60b
Make DBConnRef enforce the DB domain selected during its lifetime
and allow more nested and successive use of the same connection handle
via DBConnRef. This can avoid extra connections in some cases where
getConnection()/getConnectionRef() is used.
Also:
* Reduce the number of connection pools arrays from six to two
* Merge getLocalConnection()/getForeignConnection() into one method
* Expand various related code comments
Bug: T226595
Depends-On: If808cbab429d41e1f2289683533e4a781a4bdf5e
Change-Id: I540b08920997c57cad6445ddb09d8e663eaf4714
When tests use code that uses getConnection() to foreign domains, it changes the
DB domain of the "db" member field, which can break assertions. Use of this new
method can avoid that problem by using DBConnRef.
Bug: T316841
Change-Id: Ia0f3cf49c79affb7189801852ac7e9ec67933a3c
When parsing content for page creation, we need to be able to pass the
page language explicitly. This patch allows the language to be looped
through from ParsoidHTMLHelper via ParsoidOutputAccess into Parsoid
itself.
Change-Id: I1bbf9c2180de2d91679edbc9d73adfe44075dde3
Also improve MediaWikiIntegrationTestCase::editPage by accepting
LinkTarget objects and use services instead of static functions
Change-Id: I3d036b0837f212d3500159c1d3a3daa4e706882c
This matches the DB domain logic enforcement in the other class methods.
Cleanup several type hints in related code.
Change-Id: I6668852ccebe16349b38b5a793543bd3ec0a35b8
MediaWikiIntegrationTestCase::installMockMwServices() was changed in
I1922d9b903dcafb83691c2d96790f72747eeef9c to no longer apply default
overrides. This was left to overrideMwServices().
This caused parser tests to run without the necessary config overrides,
since it calls installMockMwServices(), but cannot make use of
overrideMwServices().
This changes installMockMwServices() so it will apply the default
overrides when called with no parameters.
Bug: T312709
Change-Id: I898927717ce961d98617a7fcd9c7fa8e19bec412
If an extension uses this service somewhere, redefining before
resetting it breaks the tests.
Follows-up: Ia60cb0bc18b235f23d9778da8241f65accfc0d35
Change-Id: Ie930f2bbab3d31831751caa1ca342fd9a023b19b
As we slowly move away from using globals, overrideConfigValue()
and overrideConfigValues() were introduced as a way to override
test configs between tests.
Under the hood, it just calls setMwGlobals() which resets services,
so take note.
Part 1: Directories covered are: languages/, maintenance/, tests/,
structure/ and includes/Permissions/.
Depends-On: I618b16c6d99c94eb2e7edcf05e888a65f7156754
Change-Id: If56f7d10d79f3a9824a52091a2b544d8653dd7b6
This sets MainCacheType to 'hash', so the main cache is functional
within test cases. Between tests we are already calling ObjectCache::clear,
so the cache will not leak data into other test cases.
It turned out that the way we have been overriding configuration
settings in MediaWikiIntegrationTestCase is insufficient, since the
overrides would only apply in the main Config object, not in global
variables. This means they could not be overwritten with setMwGlobals.
So this patch also changes how we apply config overrides for test setup.
Config overrides that happen during tests work as before.
Depends-On: Ic36e92b73f22fd64e2d0b680d8e900f598158460
Change-Id: Ia60cb0bc18b235f23d9778da8241f65accfc0d35
The main object cache is disabled during testing. Some integration tests
need it though. This provides a clean way to enable it, to replace the hacks
that were used so far.
Note that we may want to enable the main cache during testing soon. When
that happens, this method is still useful to disable the cache in certain
tests, and to set a specific cache instance.
Change-Id: I04ae1bf1b6b2c8f6310acd2edf89459d01a9c870
This implements config overrides with a HashConfig that is layered on
top of the base config, so we can move away from global variables.
Global variables are still updated using setMwGlobals, for compatibility
with code that is still reading configuration from global variables.
This fixes an issue with the default overrides not being applied to
global variables.
Change-Id: I1922d9b903dcafb83691c2d96790f72747eeef9c
overrideConfigValues() is introduced as a replacement for
setMwGlobals(). Since we are moving away from reading configuration
from global variables, test cases should not use global variables to set
configuration.
Bug: T294739
Change-Id: I9d41045bd13932bd853f53e00322233fc4f1321c
This caused unexpected problems with no obvious fixes. Needs more work.
This reverts commit 7238dff532.
Bug: T310255
Bug: T90875
Change-Id: I3758cbb6d0029b20ec1b0f67dbf2f422031c50ae
* switch to phpunit.xml.dist instead of suites.xml
* switch composer.json to vendor/bin/phpunit
* tests/phpunit/phpunit.php is retained but will be removed after CI
jobs and other references on
codesearch (https://codesearch.wmcloud.org/search/?q=tests%2Fphpunit%2Fphpunit.php&i=nope&files=&excludeFiles=&repos=)
are removed
* add a default bootstrap.integration.php; unit tests in
composer.json use the non-MW bootstrap file (bootstrap.php)
* Migrate the phpunit.php logic into tests/phpunit/BootstrapIntegrationWrapper.php
Depends-On: I19d560bdcdb2ee914ab055e094841f2b5db8be55
Depends-On: Ib23209fc3b095e3c012ed84ce5c11f8b2d27b898
Co-authored-by: Daimona Eaytoy <daimona.wiki@gmail.com>
Bug: T227900
Bug: T90875
Change-Id: I82045c207738d152d5b0006f353637cfaa40bb66
DefaultSettings.php has been replaced by MainConfigSchema.
Loading DefaultSettings.php is deprecated.
Code that needs to have access to configuration defaults should use the
ConfigSchema service object.
Bug: T300129
Change-Id: I7b2c0ca95a78990be1cdb9dd9ace92f6dcf1af15
This would simplify the code for its users a lot.
Bug: T255493
Depends-On: I6ab4440a13f4682dd3a6e9cfc6c629222fbeab8a
Change-Id: I6e7544763bde56fc1e19de0358b71ba984a978ca
The global variable $IP has been replaced by the MW_INSTALL_PATH
constant. Clarify the continued use of $IP on Setup.php.
Change-Id: I157abfd9049fb8382da53005a084ab86f47e8d8a
TestSetup seems a nice place for this function. This way, it can also be
reused in the other boostrap file whilst we migrate the entrypoint.
Also, replace the check in MediaWikiIntegrationTestCase with another
constant; this also makes it easier to understand when exactly that code
should run.
Bug: T90875
Change-Id: I7858d982378ab4b6f11c4e9bf955d83d1acbc85d
This reverts commit 17bab86e7a.
Extension failures (ref T304625) have since been fixed.
Bug: T225730
Change-Id: Ia452e076bdce45f1151f970c16837b80813ee08a
Signal that the test run needs to stop and record the exception via
addError() so that it will be displayed in the output and the exit
code will reflect test failure.
Previously, errors would cause the tests to suddenly stop, and any
buffered output about previous errors, warnings, and failed tests
was lost.
Bug: T292239
Change-Id: I5b2a7bcbb38760fcd10fccfbf000f4a8511f8774
This adds full integration tests for extension registration, ensuring
that ExtensionProcessor and ExtensionRegistry work together as expected.
The existing tests for ExtensionProcessor and ExtensionRegistry are
converted to "pure" unit tests.
This change is intended to protect against bugs while refactoring
ExtensionProcessor and ExtensionRegistry to better integrate with the
new SettingsBuilder class.
Bug: T297166
Change-Id: I2d9cc373b8a4aa014aef93b0a8e8d83758851783
BackupDumperPageTest called MediaWikiIntegrationTestCase::
setupDatabaseWithTestPrefix() on a new private connection, overwriting
self::$dbClone. This can cause a fatal error on shutdown due to
self::$dbClone->destroy() being called after connection close. Hopefully
it also fixes the CI failure observed at I200f90e413b8a725828745f81925b.
Also, the method was documented as returning bool, but in fact it always
returned true.
So, move the responsibility for setting self::$dbClone to the only
caller where that makes sense. Have BackupDumperPageTest call
CloneDatabase::destroy() during test teardown.
Change-Id: I2a4cefe6207c02cc12b906d66f6016440e16b249