Repository navigation
·
1 commit
to 13.5
since this release
Immutable
release. Only release title and notes can be modified.
Added
- #7038:
--show-effective-configurationCLI option to show what a configuration will execute, without executing it - #7039:
TestCase::suspendOutputBuffering()andTestCase::resumeOutputBuffering()methods for capturing the output of a test method thatTestCase::invokeTestMethod()runs in a coroutine with its own output buffers - #7049:
--random-seed <N>CLI option - #7086:
--triggering-tests-limitCLI option andtriggeringTestsLimitXML attribute to group and limit the tests listed for each issue - #7146: Run receipt that records what was run and how the run ended in Open Test Reporting logfile and the compact output
- #7198: Result of the test run in JSON format (
--json,--log-json) - phpunit/php-code-coverage #1056: The code coverage report in XML format includes branch and path coverage
- phpunit/php-code-coverage 14.6: The code coverage report in HTML format shows, next to a line that is covered, how many tests cover it or, when the code coverage driver collects hit counts, how often the line was executed
- phpunit/php-code-coverage 14.6: The code coverage report in HTML format has navigation between the pieces of code that are not covered: the
nandpkeys, and two buttons, jump to the next and to the previous one --gaps-onlyCLI option andgapsOnlyattribute for the<jsonl>element of the XML configuration file to limit the code coverage report in JSONL format to what is not covered:coverage.jsonlthen has no record for a file that has nothing that is not covered, and no record for a method or function that is covered--details-limit <n>CLI option to limit each message, each stack trace, and the output of each test that the compact output (--compact) prints, and each message, diff, and stack trace of the result of the test run in JSON format that is the output of--json, to<n>charactersexitCode()andsignal()methods on theTestRunner\ChildProcessFinishedandTestRunner\ChildProcessErroredevents for the exit code of a child process and the signal that terminated itoutcome()method on theApplication\Finishedevent for how the test run ended, as the run receipt records it: its status, the numbers of tests by outcome, and the numbers of the issues triggered by tests and by the test runner
Changed
- #7049: Renamed
phpunit:randomOrderSeedtophpunit:randomSeedin Open Test Reporting XML logfiles - #7051: Seed random number generators using
--random-seed <N>, regardless of whether PHPUnit needs random number generation - phpunit/php-code-coverage #1407: The line of the right operand of a
&&(orand) that spans multiple lines is no longer reported as covered when it was not executed, as this operand is not evaluated when the left operand is false - phpunit/php-code-coverage 14.6: The line of the right operand of a
||(oror) that spans multiple lines, and the lines of a method call or property fetch after?->that starts on a line of its own, are no longer reported as covered when they were not executed - phpunit/php-code-coverage 14.6: On PHP 8.6 and later, the executable lines of a file are determined from its bytecode instead of from its syntax when OPcache is enabled, compiles the code without optimizations (
opcache.optimization_level=0), and does not skip recently modified files (opcache.file_update_protection=0): lines that PHP attributes no code to, such as the continuation lines of a multi-line function call, are then no longer counted as executable - phpunit/php-code-coverage 14.6: Processing the code coverage data of a test, and merging the code coverage data of tests that are run in separate processes, is faster
- phpunit/php-code-coverage 14.6: The code coverage report in HTML format lists a directory that contains nothing but another directory, or nothing but a single file, together with what it contains instead of requiring a click for each level
- phpunit/php-code-coverage 14.6: The view for branch coverage of the code coverage report in HTML format shows, next to a line that a branch with more than one successor ends on, which of the edges out of that branch were taken
- The lines below the header of a record of the compact output (
--compact) are now indented by two spaces: a message, a diff, a stack trace, and the output of a test can no longer be mistaken for the header of a record, the summary line, or the receipt of the test run, which begin in the first column - The compact output (
--compact) now prints the path of a file inside the working directory relative to the working directory, which the receipt of the test run names, in the frames of a stack trace, in the header of the record for an issue, and in the location of a test that triggered an issue: the path to the project is no longer repeated in each of them, and a file outside the working directory stands out - The summary line of the compact output (
--compact) no longer begins withOKwhen no test failed or errored but the test run was cut short: it begins withSTOPPEDwhen a--stop-on-*option ended the test run, withINTERRUPTEDwhen a signal did, and withTIME LIMIT EXCEEDEDwhen the time limit configured using--timeoutwas exceeded - The compact output (
--compact) now prints that the test run was interrupted by a signal as a record of its own, after the summary line - The summary of the default output no longer says
OKwhen no test failed or errored but the test run was cut short: it saysSTOPPED!when a--stop-on-*option ended the test run,INTERRUPTED!when a signal did, andTIME LIMIT EXCEEDED!when the time limit configured using--timeoutwas exceeded, followed by the numbers of tests and assertions - The default output now says which
--stop-on-*option stopped the test run, in a line of its own before the result is printed, for instanceThe test run was stopped by --stop-on-failure.: a test run that was stopped after a test failed or errored was reported exactly like a test run that ran every selected test - A test run for which a time limit is configured using
--timeoutis no longer started when the time limit cannot be enforced because the pcntl extension is not available: the test runner then exits with an error message and shell exit code2, instead of only checking the time limit between two tests - A test run is no longer started when the cache directory that is configured using
--cache-directoryor thecacheDirectoryattribute cannot be created or cannot be written to: the test runner then exits with an error message that names the directory and with shell exit code2, before the bootstrap script, the extensions, or the tests are loaded. This does not depend on whether the test run would write to the cache directory, and it also applies to--warm-coverage-cache. Until now, such a test run recorded its history elsewhere, or not at all, without saying so, or crashed when code coverage was collected - A cache directory configured using
--cache-directorythat cannot be created is no longer replaced, without saying so, by the cache directory that is configured in the XML configuration file - A PHP process that ends before the test run did and while no test is running, for instance because a bootstrap script, an extension, a data provider, or a before-first-test method calls
exit(), or because PHP raises an error that ends the process while a code coverage report is written, is now reported as a premature end, as it already is when a test is running: a message such asFatal error: Premature end of PHP process while the bootstrap script was loaded.is printed and the shell exit code is2, also whenexit(0)was called - The compact output (
--compact) and the result of the test run in JSON format (--json,--log-json) now record a test run that did not reach its end because the PHP process ended while a bootstrap script, an extension, or the test suite was loaded, while tests were executed, or while the result of the test run was reported: the receipt and the JSON document are written with the statusended-prematurely - The Open Test Reporting XML logfile (
--log-otr) of a test run that did not reach its end, because the PHP process ended although the test runner did not end it, because the test runner crashed, or because a second interrupt signal (SIGINT) ended the test run at once, is now a complete document: the test and the test suites that were not finished are reported as aborted, and thephpunit:outcomeelement is written with the statusended-prematurely,crashed, orinterruptedand says why the test run did not reach its end in itsphpunit:reasonelement - The compact output (
--compact) and the result of the test run in JSON format (--json,--log-json) now record a test run during which the test runner crashed, with the statuscrashed, and a test run that a second interrupt signal (SIGINT) ended at once, with the statusinterrupted - The compact output (
--compact) now records a test run that is not started, for instance because the cache directory cannot be written to, because the bootstrap script or a test file cannot be loaded, or because the time limit configured using--timeoutcannot be enforced: the reason is printed as aNOT STARTEDrecord, followed by the receipt of the test run with the statusnot-startedand the shell exit code, instead of as a line of text without a receipt - The Open Test Reporting XML logfile (
--log-otr) of a test run that is not started, for instance because the cache directory cannot be written to or because the bootstrap script or a test file cannot be loaded, is now a complete document: thephpunit:outcomeelement is written with the statusnot-startedand says why the test run was not started in itsphpunit:reasonelement, instead of the logfile ending after the event that starts the test run, without its root element being closed - The
Application\Finishedevent is now also emitted for a test run that is not started after the extensions were loaded, for instance because a test file cannot be loaded or because the file configured using--test-id-filter-filedoes not exist: the outcome that the event carries then has the statusnot-started. A subscriber that does something when the test run has ended, for instance writing a report, is now also notified in these cases - A test run that was interrupted by a signal (
SIGINT) now ends with shell exit code130, no matter whether the tests that were run until then passed, instead of the shell exit code of a test run that ran every selected test - Before-first-test and after-last-test methods of a test class whose tests all run in separate processes are no longer called in the test runner's process
- A test that is run in a separate process and a PHPT test are now aborted when the time limit for the test run configured using
--timeoutis exceeded while they are running: the child process is terminated and the test is reported as an error, instead of the test run being stopped only after such a test has finished - A before-first-test method, an after-last-test method, a data provider, and a
SKIPIFsection of a PHPT test that is not run in a separate process are now aborted, as a test already is, when they are running in the test runner's process when the time limit for the test run configured using--timeoutis exceeded (this requires thepcntlextension) - An exceeded time limit for the test run is now also noticed, and reported using shell exit code
124, when no test is started or finished after the time limit was exceeded, for instance because it was exceeded by an after-last-test method - A test with a time limit of its own (
--enforce-time-limit) is now aborted when the time limit for the test run is exceeded before the time limit for the test - A test run whose tests have not ended two seconds after the time limit for the test run configured using
--timeoutwas exceeded, for instance because a test catches the exception it is aborted with or because the bootstrap script does not end, is now stopped: the test that was running is reported as an error, the result is printed, and the test runner exits with shell exit code124(this requires thepcntlextension) - A process that keeps the test runner from noticing that the time limit for the test run configured using
--timeoutwas exceeded, for instance one that a test started usingexec()and waits for, is now terminated one second after the time limit was exceeded, and the test runner itself is terminated when it has not ended the test run five seconds after the time limit was exceeded, for instance because thepcntlextension is not available and a test does not end (this requires theposixextension and is not available on Windows) - When a before-first-test method, for instance
setUpBeforeClass(), of a test class whose tests all run in separate processes callsmarkTestSkipped()ormarkTestIncomplete(), fails, or errors, then a separate process is now started for each test of the class and each test is reported as skipped, failed, or errored, instead of the test class being reported once as skipped, failed, or errored - Version requirements of
#[RequiresPhp],#[RequiresPhpExtension], and#[RequiresPhpunit]are handled using sebastian/version-requirement: a test errors when its version requirement is neither a version constraint such as^8.5nor a version comparison such as>= 8.5.0, for instance8.5.0RC1,8.5-dev, or>=8.3 <8.5, which were previously interpreted as>= 8.5.0RC1,8.5.*, and< 8.5, respectively
Deprecated
- #7049:
--random-order-seed <N>CLI option - Calling
markTestSkipped()ormarkTestIncomplete()in an after-test method, for instancetearDown(), or in an after-last-test method, for instancetearDownAfterClass() - Support for loading test runner extensions from PHARs using the
extensionsDirectoryXML configuration attribute
Fixed
assertFinite()does not tell PHPStan that the value is a finitefloator anint, so the type of the value is not narrowed when test code is analysed with PHPStan (this requires PHPStan 2.3.6 or newer)- The process that runs a PHPT test with an
--ENV--section is started with an environment that is built from$_SERVERinstead of the environment of the test runner's process: environment variables that were set usingputenv(), for instance those configured using<env>in the XML configuration file, are missing, and elements of$_SERVERthat are not environment variables, for instance those configured using<server>in the XML configuration file, are exported as environment variables - A test run history that cannot be written, for instance because the directory of the XML configuration file is read-only and no cache directory is configured, leads to a PHP warning that is printed as it is (
fopen(): Failed to open stream: Permission denied) instead of a test runner warning - The test runner crashes (
An error occurred inside PHPUnit.) when code coverage is collected and the directory in which the result of the static analysis is cached cannot be created: a test runner warning is now triggered and the result of the static analysis is not cached, and--warm-coverage-cachereports the directory it cannot use
Learn how to install or update PHPUnit 13.5 in the documentation.
Keep up to date with PHPUnit:
- You can follow @phpunit@phpc.social to stay up to date with PHPUnit's development.
- You can subscribe to the PHPUnit Updates newsletter to receive updates about and tips for PHPUnit.