Skip to content

Commit

Permalink
Closes #4492
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 25, 2020
1 parent 86b17e8 commit b9e8691
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog-9.5.md
Expand Up @@ -8,5 +8,6 @@ All notable changes of the PHPUnit 9.5 release series are documented in this fil

* [#4490](https://github.com/sebastianbergmann/phpunit/issues/4490): Emit Error instead of Warning when test case class cannot be instantiated
* [#4491](https://github.com/sebastianbergmann/phpunit/issues/4491): Emit Error instead of Warning when data provider does not work correctly
* [#4492](https://github.com/sebastianbergmann/phpunit/issues/4492): Emit Error instead of Warning when test double configuration is invalid

[9.5.0]: https://github.com/sebastianbergmann/phpunit/compare/9.4...master
7 changes: 0 additions & 7 deletions src/Framework/TestResult.php
Expand Up @@ -17,7 +17,6 @@
use AssertionError;
use Countable;
use Error;
use PHPUnit\Framework\MockObject\Exception as MockObjectException;
use PHPUnit\Util\ErrorHandler;
use PHPUnit\Util\ExcludeList;
use PHPUnit\Util\Printer;
Expand Down Expand Up @@ -742,12 +741,6 @@ function_exists('xdebug_start_function_monitor');
);

$risky = true;
} catch (MockObjectException $e) {
$e = new Warning(
$e->getMessage()
);

$warning = true;
} catch (AssertionFailedError $e) {
$failure = true;

Expand Down
9 changes: 9 additions & 0 deletions src/TextUI/DefaultResultPrinter.php
Expand Up @@ -26,7 +26,9 @@
use function vsprintf;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExceptionWrapper;
use PHPUnit\Framework\InvalidArgumentException;
use PHPUnit\Framework\MockObject\RuntimeException as MockObjectException;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestFailure;
Expand Down Expand Up @@ -370,6 +372,13 @@ protected function printDefectHeader(TestFailure $defect, int $count): void
protected function printDefectTrace(TestFailure $defect): void
{
$e = $defect->thrownException();

if ($e instanceof ExceptionWrapper && $e->getClassName() === MockObjectException::class) {
$this->write($e->getMessage() . PHP_EOL);

return;
}

$this->write((string) $e);

while ($e = $e->getPrevious()) {
Expand Down

0 comments on commit b9e8691

Please sign in to comment.