Skip to content

Commit

Permalink
Closes #2670
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed May 3, 2017
1 parent 2e4f066 commit 42cca1b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog-6.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes of the PHPUnit 6.2 release series are documented in this fil

## [6.2.0] - 2017-06-02

### Added

* Implemented [#2670](https://github.com/sebastianbergmann/phpunit/issues/2670): Add support for disabling the conversion of `E_DEPRECATED` to exceptions

### Changed

* When `beStrictAboutCoversAnnotation="true"` is configured or `--strict-coverage` is used then a test is now also marked as risky when it specifies units of code using `@covers` or `@uses` that are not executed by the test
Expand Down
1 change: 1 addition & 0 deletions phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
<xs:attribute name="cacheTokens" type="xs:boolean"/>
<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="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
10 changes: 10 additions & 0 deletions src/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PHPUnit\TextUI;

use PHPUnit\Framework\Error\Deprecated;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning;
use PHPUnit\Framework\Exception;
Expand Down Expand Up @@ -222,6 +223,10 @@ public function doRun(Test $suite, array $arguments = [], $exit = true)
$result->convertErrorsToExceptions(false);
}

if (!$arguments['convertDeprecationsToExceptions']) {
Deprecated::$enabled = false;
}

if (!$arguments['convertNoticesToExceptions']) {
Notice::$enabled = false;
}
Expand Down Expand Up @@ -781,6 +786,10 @@ protected function handleConfiguration(array &$arguments)
$arguments['colors'] = $phpunitConfiguration['colors'];
}

if (isset($phpunitConfiguration['convertDeprecationsToExceptions']) && !isset($arguments['convertDeprecationsToExceptions'])) {
$arguments['convertDeprecationsToExceptions'] = $phpunitConfiguration['convertDeprecationsToExceptions'];
}

if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
}
Expand Down Expand Up @@ -1040,6 +1049,7 @@ protected function handleConfiguration(array &$arguments)
$arguments['cacheTokens'] = $arguments['cacheTokens'] ?? false;
$arguments['colors'] = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
$arguments['columns'] = $arguments['columns'] ?? 80;
$arguments['convertDeprecationsToExceptions'] = $arguments['convertDeprecationsToExceptions'] ?? true;
$arguments['convertErrorsToExceptions'] = $arguments['convertErrorsToExceptions'] ?? true;
$arguments['convertNoticesToExceptions'] = $arguments['convertNoticesToExceptions'] ?? true;
$arguments['convertWarningsToExceptions'] = $arguments['convertWarningsToExceptions'] ?? true;
Expand Down
8 changes: 8 additions & 0 deletions src/Util/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* columns="80"
* colors="false"
* stderr="false"
* convertDeprecationsToExceptions="true"
* convertErrorsToExceptions="true"
* convertNoticesToExceptions="true"
* convertWarningsToExceptions="true"
Expand Down Expand Up @@ -613,6 +614,13 @@ public function getPHPUnitConfiguration()
);
}

if ($root->hasAttribute('convertDeprecationsToExceptions')) {
$result['convertDeprecationsToExceptions'] = $this->getBoolean(
(string) $root->getAttribute('convertDeprecationsToExceptions'),
true
);
}

if ($root->hasAttribute('convertErrorsToExceptions')) {
$result['convertErrorsToExceptions'] = $this->getBoolean(
(string) $root->getAttribute('convertErrorsToExceptions'),
Expand Down
1 change: 1 addition & 0 deletions tests/Util/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public function testPHPUnitConfigurationIsReadCorrectly()
'columns' => 80,
'colors' => 'never',
'stderr' => false,
'convertDeprecationsToExceptions' => true,
'convertErrorsToExceptions' => true,
'convertNoticesToExceptions' => true,
'convertWarningsToExceptions' => true,
Expand Down
1 change: 1 addition & 0 deletions tests/_files/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
columns="80"
colors="false"
stderr="false"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand Down
1 change: 1 addition & 0 deletions tests/_files/configuration_xinclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
columns="80"
colors="false"
stderr="false"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
Expand Down

0 comments on commit 42cca1b

Please sign in to comment.