Skip to content

Commit 5370de1

Browse files
Sort test methods by source code location
1 parent ab84da2 commit 5370de1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Logging/TestDox/TestMethod/TestResultCollector.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHPUnit\Logging\TestDox;
1111

1212
use function assert;
13+
use function usort;
1314
use PHPUnit\Event\Code\TestMethod;
1415
use PHPUnit\Event\Code\Throwable;
1516
use PHPUnit\Event\EventFacadeIsSealedException;
@@ -71,6 +72,14 @@ public function testMethodsGroupedByClass(): array
7172
$result = [];
7273

7374
foreach ($this->tests as $prettifiedClassName => $tests) {
75+
usort(
76+
$tests,
77+
static function (TestDoxTestMethod $a, TestDoxTestMethod $b): int
78+
{
79+
return $a->test()->line() <=> $b->test()->line();
80+
}
81+
);
82+
7483
$result[$prettifiedClassName] = TestResultCollection::fromArray($tests);
7584
}
7685

0 commit comments

Comments
 (0)