Skip to content

Commit

Permalink
Revert "Closes #5210"
Browse files Browse the repository at this point in the history
This reverts commit 205444f.
  • Loading branch information
sebastianbergmann committed Feb 18, 2023
1 parent be72e6e commit b2a8bb5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,13 @@ final public function runBare(): void
clearstatcache();

$hookMethods = (new HookMethods)->hookMethods(static::class);
$hasMetRequirements = false;
$this->numberOfAssertionsPerformed = 0;
$currentWorkingDirectory = getcwd();

try {
$this->checkRequirements();
$hasMetRequirements = true;

if ($this->inIsolation) {
$this->invokeBeforeClassHookMethods($hookMethods, $emitter);
Expand All @@ -618,11 +620,6 @@ final public function runBare(): void

$this->verifyMockObjects();
$this->invokePostConditionHookMethods($hookMethods, $emitter);
$this->invokeAfterTestHookMethods($hookMethods, $emitter);

if ($this->inIsolation) {
$this->invokeAfterClassHookMethods($hookMethods, $emitter);
}

$this->status = TestStatus::success();
} catch (IncompleteTest $e) {
Expand Down Expand Up @@ -678,6 +675,20 @@ final public function runBare(): void

$this->mockObjects = [];

// Tear down the fixture. An exception raised in tearDown() will be
// caught and passed on when no exception was raised before.
try {
if ($hasMetRequirements) {
$this->invokeAfterTestHookMethods($hookMethods, $emitter);

if ($this->inIsolation) {
$this->invokeAfterClassHookMethods($hookMethods, $emitter);
}
}
} catch (Throwable $_e) {
$e = $e ?? $_e;
}

if (isset($_e)) {
$this->status = TestStatus::error($_e->getMessage());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/end-to-end/event/test-template-methods.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Assertion Succeeded (Constraint: is true)
Post Condition Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::assertPostConditions)
Post Condition Method Finished:
- PHPUnit\TestFixture\Event\TemplateMethodsTest::assertPostConditions
Test Passed (PHPUnit\TestFixture\Event\TemplateMethodsTest::testOne)
After Test Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::tearDown)
After Test Method Finished:
- PHPUnit\TestFixture\Event\TemplateMethodsTest::tearDown
Test Passed (PHPUnit\TestFixture\Event\TemplateMethodsTest::testOne)
Test Finished (PHPUnit\TestFixture\Event\TemplateMethodsTest::testOne)
Test Preparation Started (PHPUnit\TestFixture\Event\TemplateMethodsTest::testTwo)
Before Test Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::setUp)
Expand All @@ -64,10 +64,10 @@ Assertion Succeeded (Constraint: is true)
Post Condition Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::assertPostConditions)
Post Condition Method Finished:
- PHPUnit\TestFixture\Event\TemplateMethodsTest::assertPostConditions
Test Passed (PHPUnit\TestFixture\Event\TemplateMethodsTest::testTwo)
After Test Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::tearDown)
After Test Method Finished:
- PHPUnit\TestFixture\Event\TemplateMethodsTest::tearDown
Test Passed (PHPUnit\TestFixture\Event\TemplateMethodsTest::testTwo)
Test Finished (PHPUnit\TestFixture\Event\TemplateMethodsTest::testTwo)
After Last Test Method Called (PHPUnit\TestFixture\Event\TemplateMethodsTest::tearDownAfterClass)
After Last Test Method Finished:
Expand Down
2 changes: 2 additions & 0 deletions tests/end-to-end/regression/5210.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $_SERVER['argv'][] = __DIR__ . '/5210/Issue5210Test.php';
require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--XFAIL--
https://github.com/sebastianbergmann/phpunit/issues/5210
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Expand Down

0 comments on commit b2a8bb5

Please sign in to comment.