Skip to content

Commit e07878b

Browse files
We should be able to assume that every Test is also a Reorderable
1 parent 48d95b1 commit e07878b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/Runner/TestSuiteSorter.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use function array_merge;
1414
use function array_reverse;
1515
use function array_splice;
16+
use function assert;
1617
use function count;
1718
use function in_array;
1819
use function max;
@@ -152,9 +153,7 @@ private function addSuiteToDefectSortOrder(TestSuite $suite): void
152153
$max = 0;
153154

154155
foreach ($suite->tests() as $test) {
155-
if (!$test instanceof Reorderable) {
156-
continue;
157-
}
156+
assert($test instanceof Reorderable);
158157

159158
if (!isset($this->defectSortOrder[$test->sortId()])) {
160159
$this->defectSortOrder[$test->sortId()] = $this->cache->status($test->sortId())->asInt();
@@ -216,9 +215,8 @@ private function sortBySize(array $tests): array
216215
*/
217216
private function cmpDefectPriorityAndTime(Test $a, Test $b): int
218217
{
219-
if (!($a instanceof Reorderable && $b instanceof Reorderable)) {
220-
return 0;
221-
}
218+
assert($a instanceof Reorderable);
219+
assert($b instanceof Reorderable);
222220

223221
$priorityA = $this->defectSortOrder[$a->sortId()] ?? 0;
224222
$priorityB = $this->defectSortOrder[$b->sortId()] ?? 0;
@@ -241,9 +239,8 @@ private function cmpDefectPriorityAndTime(Test $a, Test $b): int
241239
*/
242240
private function cmpDuration(Test $a, Test $b): int
243241
{
244-
if (!($a instanceof Reorderable && $b instanceof Reorderable)) {
245-
return 0;
246-
}
242+
assert($a instanceof Reorderable);
243+
assert($b instanceof Reorderable);
247244

248245
return $this->cache->time($a->sortId()) <=> $this->cache->time($b->sortId());
249246
}

0 commit comments

Comments
 (0)