|
4 | 4 |
|
5 | 5 | namespace DocbookCS\Tests\Unit\Report\Reporter; |
6 | 6 |
|
| 7 | +use DocbookCS\RelativePath; |
7 | 8 | use DocbookCS\Report\FileReport; |
8 | 9 | use DocbookCS\Report\Report; |
9 | 10 | use DocbookCS\Report\Reporter\CheckstyleReporter; |
10 | 11 | use DocbookCS\Report\Severity; |
11 | 12 | use DocbookCS\Report\Violation; |
12 | 13 | use PHPUnit\Framework\Attributes\CoversClass; |
13 | 14 | use PHPUnit\Framework\Attributes\Test; |
| 15 | +use PHPUnit\Framework\Attributes\UsesClass; |
14 | 16 | use PHPUnit\Framework\TestCase; |
15 | 17 |
|
16 | 18 | #[ |
17 | 19 | CoversClass(CheckstyleReporter::class), |
18 | 20 | CoversClass(FileReport::class), |
19 | 21 | CoversClass(Report::class), |
20 | 22 | CoversClass(Violation::class), |
| 23 | + // |
| 24 | + UsesClass(RelativePath::class), |
21 | 25 | ] |
22 | 26 | final class CheckstyleReporterTest extends TestCase |
23 | 27 | { |
@@ -113,6 +117,23 @@ public function itIncludesFileNodeWithNameAttribute(): void |
113 | 117 | self::assertSame('src/broken.xml', $fileNodes->item(0)?->getAttribute('name')); |
114 | 118 | } |
115 | 119 |
|
| 120 | + #[Test] |
| 121 | + public function itRendersAbsoluteFilePathRelativeToWorkingDirectory(): void |
| 122 | + { |
| 123 | + $fileReport = new FileReport((getcwd() ?: '') . '/src/broken.xml'); |
| 124 | + $fileReport->addViolation($this->createViolation()); |
| 125 | + |
| 126 | + $report = new Report(); |
| 127 | + $report->addFileReport($fileReport); |
| 128 | + |
| 129 | + $dom = $this->parseOutput($this->reporter->generate($report)); |
| 130 | + |
| 131 | + self::assertSame( |
| 132 | + 'src/broken.xml', |
| 133 | + $dom->getElementsByTagName('file')->item(0)?->getAttribute('name'), |
| 134 | + ); |
| 135 | + } |
| 136 | + |
116 | 137 | #[Test] |
117 | 138 | public function itSetsLineAttribute(): void |
118 | 139 | { |
|
0 commit comments