Leave `composer phpunit` as the main PHPUnit entry point, a single
config file (phpunit.xml.dist) and a single bootstrap (bootstrap.php).
Deprecate the `composer phpunit:entrypoint`, making it print a
deprecation message and then fall back to `composer phpunit`. Deprecate
boostrap.integration.php as well. Update the release notes accordingly.
Add a temporary PHPUnit extension, only enabled in suite.xml, that
prints a deprecation message. Define a new constant in phpunit.php to
avoid printing 2 deprecation messages when phpunit.php is used (as it
auto-defaults to suite.xml).
Add some documentation to bootstrap.php.
Bug: T227900
Depends-On: Ie91c9f2882f12fd8ea822529528dd1dd9efe89db
Change-Id: If2ffe0522422fd6aadcc08988789d98c2403fc48
Add utility methods to TestSetup and call them from the bootstrap file.
Also call the same method to load settings from
MediaWikiIntegrationTestCase when invoked via the unit tests entry
point. This also fixes a couple bug in the deferred setup scenario where
setLoadTestClassesAndNamespaces wasn't called, and the error handler
wasn't reset (T227900#9003435).
Make MediaWikiIntegrationTestCase not try to load settings more than
once. Trying to do so should probably be mostly harmless because of the
require_once usage, but it's also unnecessary and this change avoids any
chance of unwanted side effects.
Also use MW_INSTALL_PATH instead of $IP in bootstrap.php.
Bug: T227900
Change-Id: I7090976435e7e2d1264ee345e2670baaccf532ea
This resolves an existing TODO in the code. Note that hooks were
deprecated in PHPUnit 9 and replaced by events in PHPUnit 10. However,
PHPUnit 9 does not provide any alternative. Also, PHPUnit 10 has a
requirement of PHP >= 8.1, so we won't update to it any time soon.
Note that this extension isn't needed for unit tests, but it's added to
the unit config file anyway for consistency, given we're going to have a
single config file in the near future.
Bug: T227900
Change-Id: I0a79ee8a9f7f8c8a176acfad9bd26486d038d31f
- Move handling of PHPUNIT_WIKI to the common bootstrap, the values
might be needed in integration tests.
- Add method to TestSetup for checking composer.lock, and use it in both
bootstraps. This cannot be moved to the common bootstrap yet, because
it needs to run after loading MW.
- In MediaWikiIntegrationTestCase::
initializeForStandardPhpunitEntrypointIfNeeded, use global $IP instead
of redefining it.
Bug: T227900
Change-Id: I050dcc36b814abd7b909eaaf6d356ecd0d3a0c80
- Remove display_errors override. This was copied from the Maintenance
class in Id6d7e9db, but it's unnecessary here because we configure
PHPUnit to fail if a PHP notice/warning is emitted. This causes the
warning/notice to be converted to a failed assertion handled by
PHPUnit.
- Remove code that turned off output buffering, also copied from
Maintenance. I'd say it's unlikely for output buffering to enabled at
that point, and most importantly, we would enable output buffering a
bit later anyway.
- Call ob_start earlier, so that it also works for anything that prints
messages even before dataProviders are run (e.g., setup or
bootstrap code).
- Move the ob_start call to the common bootstrap, as unit tests are
still affected by the same issue that the call aimed to fix.
- Print the PHP version immediately, and do that for unit tests too.
- Get rid of MediaWikiCliOptions in favour of private code in
MediaWikiIntegrationTestCase, which is the only class supposed to
access those settings.
- Set wgCommandLineMode in the common bootstrap. Assume that nobody is
changing its value randomly in config files because that'd be
ill-advised.
- Inline code for setting memory_limit and max_execution_time, and run
it only after loading the settings. Doing that earlier is pointless,
because these values are already set in suite.xml.
- Update obsolete comment mentioning PHPUnitMaintClass, which is long
gone. In the current code, this is the only way (besides PHPUnit
hooks/events) to run code before PHP exits. Also remove the second
part because we're now on PHPUnit 9, so this should be actionable now.
Remove link to the PHPUnit documentation as it no longer works. There
doesn't seem to be an equivalent link for PHPUnit 9, perhaps because
hooks were replaced with events. There //is// an equivalent link in
the PHPUnit 10 documentation (for events), but we're not yet using it.
Change-Id: I79bbbfcfe4eab3ff5ae81b2deb6450ba06ad7611
- Consolidate the common parts into a shared bootstrap.common.php file
- Rearrange the code a bit to clarify when certain things (like globals)
are actually needed.
- Replace the bootstrap class with two global functions, and inline two
other functions.
This change should be a no-op for both unit and integration tests.
Change-Id: Ie20617ac80d12f99ceaeae53b852cc6ed76b3feb
`composer phpunit:entrypoint` should be used instead. Copy all the
setup to a new bootstrap file, with some adjustments for the bootstrap
not being in the global scope when PHPUnit loads it.
Leave the old script and bootstrap in place (e.g., for CI), but make
them print deprecation warnings.
Update the composer scripts to use the standard `phpunit` entrypoint.
The bootstrap code was copied almost verbatim from the phpunit.php
entrypoint to minimize changes. Any improvements can be done in other
patches.
Bug: T90875
Change-Id: I95a80c44f8d88c3c498efe1ae64008f0ff1eea55
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