Skip to content

Commit

Permalink
ref sebastianbergmann#2236 - Move status assignment after last occure…
Browse files Browse the repository at this point in the history
…nce of _e AND add assert
  • Loading branch information
jean authored and jean committed Dec 24, 2017
1 parent a19b93d commit dc5925a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Framework/TestCase.php
Expand Up @@ -925,11 +925,6 @@ public function runBare(): void
$e = $_e;
}

if (isset($_e)) {
$this->status = BaseTestRunner::STATUS_ERROR;
$this->statusMessage = $_e->getMessage();
}

// Clean up the mock objects.
$this->mockObjects = [];
$this->prophet = null;
Expand Down Expand Up @@ -962,6 +957,11 @@ public function runBare(): void
}
}

if (isset($_e)) {
$this->status = BaseTestRunner::STATUS_ERROR;
$this->statusMessage = $_e->getMessage();
}

\clearstatcache();

if ($currentWorkingDirectory != \getcwd()) {
Expand Down
1 change: 1 addition & 0 deletions tests/Framework/TestCaseTest.php
Expand Up @@ -175,6 +175,7 @@ public function testExceptionInTearDown(): void
$this->assertTrue($test->testSomething);
$this->assertTrue($test->assertPostConditions);
$this->assertTrue($test->tearDown);
$this->assertEquals(BaseTestRunner::STATUS_ERROR, $test->getStatus());
}

public function testNoArgTestCasePasses(): void
Expand Down

1 comment on commit dc5925a

@bigaltum
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this fix, if test stop throw \Exception, then in \PHPUnit\Framework\TestCase::tearDown() method \PHPUnit\Framework\TestCase::hasFailed() return false

Please sign in to comment.