- 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
`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
The script should never be used directly, to allow an easier migration
to vendor/bin/phpunit.
Bug: T90875
Change-Id: I8d0c4c3a9007d50f39a6bef37a0db62fe83de4d7
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
Move the relevant options to the config file instead, and add some hacky
code to force that config file if none was passed. "--help" works even
without the previous hack.
Bug: T90875
Change-Id: I84421e3eeaad0f88be83477cb99d6524abe13b77
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
Following discussion in Ibb8175981092d7f41864e641cc3c118af70a5c76, this patch
proposes to further reduce the scope of what unit tests may access, by removing
the loading of DefaultSettings and GlobalFunctions.php. This also has the
implied effect of disabling the storage backend, as well as the global service
locator.
MediaWikiTestCase is renamed to MediaWikiIntegrationTestCase so it's scope and
purpose is more clear. Whether we still need to keep `@group Database`
annotation around is debatable, as it's unclear to me what the performance costs
are of implying database access for all tests which extend IntegrationTestCase.
As far as I can tell, `@group Database` is primarily used in CI to run faster
tests before slower ones, and with the new UnitTestCase the annotation seems
redundant.
To run all testsuites, use `composer phpunit`. Other composer scripts:
- `composer phpunit:unit` to run unit tests
- `composer phpunit:integration` to run integration tests
- `composer phpunit:coverage` to generate code coverage reports from unit
tests (requires XDebug).
Note that you can pass arguments to composer scripts with `--`, e.g. `composer
phpunit:integration --exclude-group Dump`.
Other changes:
- Rename bootstrap.php to bootstrap.maintenance.php so it's clear it's part of
the legacy PHPUnit-as-maintenance-class setup
- Create new bootstrap.php which loads the minimal configuration necessary for
the tests, and do additional setup in the run() method of the unit/integration
test case classes
- Move the unit-tests.xml file to phpunit.xml.dist in preparation for this being
the default test configuration
For a follow-up patch:
- Find unit/integration tests for extensions/skins
- Migrate other test suites from suite.xml
- Support running all tests via vendor/bin/phpunit
Bug: T84948
Bug: T89432
Bug: T87781
Change-Id: Ie717b0ecf4fcfd089d46248f14853c80b7ef4a76