Skip to content

Commit

Permalink
Do not convert PHP deprecations to exceptions by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 25, 2021
1 parent 5089e6c commit fac0262
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ChangeLog-8.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil

## [8.5.21] - 2021-MM-DD

### Changed

* PHPUnit no longer converts PHP deprecations to exceptions by default (configure `convertDeprecationsToExceptions="true"` to enable this)
* The PHPUnit XML configuration file generator now configures `convertDeprecationsToExceptions="true"`

### Fixed

* [#4772](https://github.com/sebastianbergmann/phpunit/pull/4772): TestDox HTML report not displayed correctly when browser has custom colour settings
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
bootstrap="tests/bootstrap.php"
convertDeprecationsToExceptions="true"
colors="true"
verbose="true">
<testsuites>
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<xs:attribute name="cacheTokens" type="xs:boolean" default="false"/>
<xs:attribute name="colors" type="xs:boolean" default="false"/>
<xs:attribute name="columns" type="columnsType" default="80"/>
<xs:attribute name="convertDeprecationsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertDeprecationsToExceptions" type="xs:boolean" default="false"/>
<xs:attribute name="convertErrorsToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertNoticesToExceptions" type="xs:boolean" default="true"/>
<xs:attribute name="convertWarningsToExceptions" type="xs:boolean" default="true"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ final class TestResult implements Countable
/**
* @var bool
*/
private $convertDeprecationsToExceptions = true;
private $convertDeprecationsToExceptions = false;

/**
* @var bool
Expand Down
6 changes: 3 additions & 3 deletions src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ public function doRun(Test $suite, array $arguments = [], array $warnings = [],

unset($listener, $listenerNeeded);

if (!$arguments['convertDeprecationsToExceptions']) {
$result->convertDeprecationsToExceptions(false);
if ($arguments['convertDeprecationsToExceptions']) {
$result->convertDeprecationsToExceptions(true);
}

if (!$arguments['convertErrorsToExceptions']) {
Expand Down Expand Up @@ -1245,7 +1245,7 @@ private function handleConfiguration(array &$arguments): void
$arguments['cacheTokens'] = $arguments['cacheTokens'] ?? false;
$arguments['colors'] = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
$arguments['columns'] = $arguments['columns'] ?? 80;
$arguments['convertDeprecationsToExceptions'] = $arguments['convertDeprecationsToExceptions'] ?? true;
$arguments['convertDeprecationsToExceptions'] = $arguments['convertDeprecationsToExceptions'] ?? false;
$arguments['convertErrorsToExceptions'] = $arguments['convertErrorsToExceptions'] ?? true;
$arguments['convertNoticesToExceptions'] = $arguments['convertNoticesToExceptions'] ?? true;
$arguments['convertWarningsToExceptions'] = $arguments['convertWarningsToExceptions'] ?? true;
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public function getPHPUnitConfiguration(): array
if ($root->hasAttribute('convertDeprecationsToExceptions')) {
$result['convertDeprecationsToExceptions'] = $this->getBoolean(
(string) $root->getAttribute('convertDeprecationsToExceptions'),
true
false
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Util/ConfigurationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class ConfigurationGenerator
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
verbose="true">
<testsuites>
<testsuite name="default">
Expand Down
1 change: 1 addition & 0 deletions tests/unit/Util/ConfigurationGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function testGeneratesConfigurationCorrectly(): void
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
verbose="true">
<testsuites>
<testsuite name="default">
Expand Down

0 comments on commit fac0262

Please sign in to comment.