Skip to content

Commit 1743314

Browse files
committed
[BUGFIX] Suite nesting may fatal
Reordering may fatal since change 95ac72f: testSuiteContainsOtherSuites() may also contain tests next to suites in its array, calling ->tests() on non suite objects then fatals. Sanitize randomizeSuiteThatContainsOtherSuites() a bit to cope with that.
1 parent 90df480 commit 1743314

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/PHPUnitRandomizer/Randomizer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
3939
{
4040
$order = 0;
4141
foreach ($suite->tests() as $test) {
42-
if($this->testSuiteContainsOtherSuites($test)){
42+
if ($test instanceof \PHPUnit\Framework\TestSuite && $this->testSuiteContainsOtherSuites($test)) {
4343
$this->randomizeSuiteThatContainsOtherSuites($test, $seed);
4444
}
45-
$this->randomizeSuite($test, $seed, $this->order);
45+
if ($test instanceof \PHPUnit\Framework\TestSuite) {
46+
$this->randomizeSuite($test, $seed, $this->order);
47+
}
4648
$this->order++;
4749
}
4850
return $this->randomizeSuite($suite, $seed, $this->order, false);

0 commit comments

Comments
 (0)