|
9 | 9 | */ |
10 | 10 | namespace PHPUnit\Runner\Baseline; |
11 | 11 |
|
| 12 | +use function array_keys; |
12 | 13 | use function realpath; |
13 | 14 | use PHPUnit\Framework\Attributes\CoversClass; |
14 | 15 | use PHPUnit\Framework\Attributes\Group; |
@@ -45,6 +46,27 @@ public function testGroupsIssuesByFileAndLine(): void |
45 | 46 | $this->assertTrue($this->issue()->equals($line[0])); |
46 | 47 | } |
47 | 48 |
|
| 49 | + public function testCanonicalizesIssuesByFileLineAndDescription(): void |
| 50 | + { |
| 51 | + $fileA = realpath(__DIR__ . '/../../../_files/baseline/AnotherFileWithIssues.php'); |
| 52 | + $fileB = realpath(__DIR__ . '/../../../_files/baseline/FileWithIssues.php'); |
| 53 | + |
| 54 | + $baseline = new Baseline; |
| 55 | + |
| 56 | + $baseline->add(Issue::from($fileB, 11, null, 'Undefined variable $c')); |
| 57 | + $baseline->add(Issue::from($fileB, 10, null, 'b: Undefined variable $b')); |
| 58 | + $baseline->add(Issue::from($fileB, 10, null, 'a: Undefined variable $b')); |
| 59 | + $baseline->add(Issue::from($fileA, 10, null, 'Undefined variable $y')); |
| 60 | + |
| 61 | + $issues = $baseline->groupedByFileAndLine(); |
| 62 | + |
| 63 | + $this->assertSame([$fileA, $fileB], array_keys($issues)); |
| 64 | + $this->assertSame([10, 11], array_keys($issues[$fileB])); |
| 65 | + |
| 66 | + $this->assertSame('a: Undefined variable $b', $issues[$fileB][10][0]->description()); |
| 67 | + $this->assertSame('b: Undefined variable $b', $issues[$fileB][10][1]->description()); |
| 68 | + } |
| 69 | + |
48 | 70 | public function testCanBeQueried(): void |
49 | 71 | { |
50 | 72 | $baseline = new Baseline; |
|
0 commit comments