Skip to content

Commit

Permalink
Destroy TestCase object after its test was run
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 14, 2024
1 parent cb40dd5 commit 80ff5f5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Framework/TestSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,30 @@ public function run(): void
}

$test->run();

foreach (array_keys($this->tests) as $key) {
if ($test === $this->tests[$key]) {
unset($this->tests[$key]);

break;
}
}

if ($test instanceof TestCase || $test instanceof self) {
foreach ($test->groups() as $group) {
if (!isset($this->groups[$group])) {
continue;
}

foreach (array_keys($this->groups[$group]) as $key) {
if ($test === $this->groups[$group][$key]) {
unset($this->groups[$group][$key]);

break;
}
}
}
}
}

$this->invokeMethodsAfterLastTest($emitter);
Expand Down

0 comments on commit 80ff5f5

Please sign in to comment.