Skip to content

Commit 80ff5f5

Browse files
Destroy TestCase object after its test was run
1 parent cb40dd5 commit 80ff5f5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Framework/TestSuite.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,30 @@ public function run(): void
347347
}
348348

349349
$test->run();
350+
351+
foreach (array_keys($this->tests) as $key) {
352+
if ($test === $this->tests[$key]) {
353+
unset($this->tests[$key]);
354+
355+
break;
356+
}
357+
}
358+
359+
if ($test instanceof TestCase || $test instanceof self) {
360+
foreach ($test->groups() as $group) {
361+
if (!isset($this->groups[$group])) {
362+
continue;
363+
}
364+
365+
foreach (array_keys($this->groups[$group]) as $key) {
366+
if ($test === $this->groups[$group][$key]) {
367+
unset($this->groups[$group][$key]);
368+
369+
break;
370+
}
371+
}
372+
}
373+
}
350374
}
351375

352376
$this->invokeMethodsAfterLastTest($emitter);

0 commit comments

Comments
 (0)