Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3031 - now based on 7.0.2 #3034

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Framework/TestCase.php
Expand Up @@ -748,7 +748,9 @@ public function runBare(): void
$this->status = BaseTestRunner::STATUS_FAILURE;
$this->statusMessage = $e->getMessage();
} catch (Throwable $_e) {
$e = $_e;
$e = $_e;
$this->status = BaseTestRunner::STATUS_ERROR;
$this->statusMessage = $_e->getMessage();
}

$this->mockObjects = [];
Expand Down
8 changes: 8 additions & 0 deletions tests/Framework/TestCaseTest.php
Expand Up @@ -178,6 +178,14 @@ public function testExceptionInTearDown(): void
$this->assertEquals(BaseTestRunner::STATUS_ERROR, $test->getStatus());
}

public function testExceptionInTestIsDetectedInTeardown(): void
{
$test = new \ExceptionInTestDetectedInTeardown('testSomething');
$test->run();

$this->assertTrue($test->exceptionDetected);
}

public function testNoArgTestCasePasses(): void
{
$result = new TestResult;
Expand Down
21 changes: 21 additions & 0 deletions tests/_files/ExceptionInTestDetectedInTeardown.php
@@ -0,0 +1,21 @@
<?php
use PHPUnit\Framework\TestCase;

use PHPUnit\Runner\BaseTestRunner;

class ExceptionInTestDetectedInTeardown extends TestCase
{
public $exceptionDetected = false;

public function testSomething()
{
throw new Exception;
}

protected function tearDown(): void
{
if (BaseTestRunner::STATUS_ERROR == $this->getStatus()) {
$this->exceptionDetected = true;
}
}
}