| Q |
A |
| Bug report? |
yes |
| Feature request? |
no |
| BC Break report? |
yes-ish? :) |
| RFC? |
no |
| Symfony version |
3.4.5 - 4.0.8 |
| PHPUnit version |
^7 |
When an exception is thrown inside data provider, PHPUnit bridge crashes with fatal error.
Smallest repro script:
<?php
class FailTest extends PHPUnit\Framework\TestCase
{
public function epicFail() : array
{
throw new RuntimeException();
}
/**
* @dataProvider epicFail
*/
public function testFail() : void
{
$this->fail();
}
}
Output:
$ vendor/bin/phpunit FailTest.php
PHPUnit 7.1.1 by Sebastian Bergmann and contributors.
Testing FailTest
PHP Fatal error: Uncaught TypeError: Return value of PHPUnit\Framework\TestCase::getTestResultObject() must be an instance of PHPUnit\Framework\TestResult, null returned in /tmp/bridge-fail/vendor/phpunit/phpunit/src/Framework/TestCase.php:1035
Stack trace:
#0 /tmp/bridge-fail/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerTrait.php(182): PHPUnit\Framework\TestCase->getTestResultObject()
#1 /tmp/bridge-fail/vendor/symfony/phpunit-bridge/Legacy/SymfonyTestsListenerForV7.php(55): Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait->startTest(Object(PHPUnit\Framework\WarningTestCase))
#2 /tmp/bridge-fail/vendor/phpunit/phpunit/src/Framework/TestResult.php(372): Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7->startTest(Object(PHPUnit\Framework\WarningTestCase))
#3 /tmp/bridge-fail/vendor/phpunit/phpunit/src/Framework/TestResult.php(584): PHPUnit\Framework\TestResult->startTest(Object(PHPUnit\Framework\WarningTestCase))
#4 /tmp/bridge-fail/vendor/phpunit/phpunit/src/Framework/TestCase.php(796): PHPUnit\Frame in /tmp/bridge-fail/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1035
Config:
<?xml version="1.0" encoding="utf-8"?>
<phpunit>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
Observed in Doctrine DBAL: doctrine/dbal#3049
When an exception is thrown inside data provider, PHPUnit bridge crashes with fatal error.
Smallest repro script:
Output:
Config:
Observed in Doctrine DBAL: doctrine/dbal#3049