Skip to content

Commit 38f532c

Browse files
committed
Increase test coverage for MarkdownFormatter
1 parent b4ead39 commit 38f532c

File tree

3 files changed

+90
-15
lines changed

3 files changed

+90
-15
lines changed

phpunit.xml.dist

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="./tests/bootstrap.php" backupGlobals="true" colors="true" forceCoversAnnotation="true">
3-
<coverage>
4-
<include>
5-
<directory>./src</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.0/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
forceCoversAnnotation="true"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTodoAnnotatedTests="true"
9+
verbose="true">
10+
811
<testsuites>
912
<testsuite name="Unit Tests">
1013
<directory>tests</directory>
1114
</testsuite>
1215
</testsuites>
16+
17+
<filter>
18+
<whitelist processUncoveredFilesFromWhitelist="true">
19+
<directory suffix=".php">src</directory>
20+
</whitelist>
21+
</filter>
1322
</phpunit>

tests/App/Generator/Formatter/MarkdownFormatterTest.php

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ final class MarkdownFormatterTest extends TestCase
1717
{
1818
private MarkdownFormatter $formatter;
1919

20+
private function createSniff(): Sniff
21+
{
22+
return new Sniff(
23+
'Standard.Category.My',
24+
'',
25+
[],
26+
new UrlList([]),
27+
'',
28+
[],
29+
[]
30+
);
31+
}
32+
2033
/** @test */
2134
public function formatDescription(): void
2235
{
@@ -30,16 +43,14 @@ public function formatDescription(): void
3043
);
3144
}
3245

33-
private function createSniff(): Sniff
46+
/** @test */
47+
public function formatDescription_WithBlankString_ReturnBlankString(): void
3448
{
35-
return new Sniff(
36-
'Standard.Category.My',
37-
'',
38-
[],
39-
new UrlList([]),
49+
self::assertEquals(
4050
'',
41-
[],
42-
[]
51+
$this->formatter->formatDescription(
52+
$this->createSniff()->withDescription('')
53+
)
4354
);
4455
}
4556

@@ -58,6 +69,17 @@ public function formatDocblock(): void
5869
);
5970
}
6071

72+
/** @test */
73+
public function formatDocblock_WithBlankString_ReturnBlankString(): void
74+
{
75+
self::assertEquals(
76+
'',
77+
$this->formatter->formatDocblock(
78+
$this->createSniff()->withDocblock('')
79+
)
80+
);
81+
}
82+
6183
/** @test */
6284
public function formatComparisons(): void
6385
{
@@ -84,6 +106,17 @@ public function formatComparisons(): void
84106
);
85107
}
86108

109+
/** @test */
110+
public function formatComparisons_WithEmptyList_ReturnBlankString(): void
111+
{
112+
self::assertEquals(
113+
'',
114+
$this->formatter->formatComparisons(
115+
$this->createSniff()->withDiffs([])->getDiffs()
116+
)
117+
);
118+
}
119+
87120
/** @test */
88121
public function formatPublicProperties(): void
89122
{
@@ -103,6 +136,17 @@ public function formatPublicProperties(): void
103136
);
104137
}
105138

139+
/** @test */
140+
public function formatPublicProperties_WithEmptyList_ReturnBlankString(): void
141+
{
142+
self::assertEquals(
143+
'',
144+
$this->formatter->formatPublicProperties(
145+
$this->createSniff()->withProperties([])->getProperties()
146+
)
147+
);
148+
}
149+
106150
/** @test */
107151
public function formatSeeAlso(): void
108152
{
@@ -122,6 +166,17 @@ public function formatSeeAlso(): void
122166
);
123167
}
124168

169+
/** @test */
170+
public function formatSeeAlso_WithEmptyList_ReturnBlankString(): void
171+
{
172+
self::assertEquals(
173+
'',
174+
$this->formatter->formatSeeAlso(
175+
$this->createSniff()->withUrls(new UrlList([]))->getUrls()
176+
)
177+
);
178+
}
179+
125180
/** @test */
126181
public function formatViolations(): void
127182
{
@@ -164,6 +219,17 @@ public function formatViolations(): void
164219
);
165220
}
166221

222+
/** @test */
223+
public function formatViolations_WithEmptyList_ReturnBlankString(): void
224+
{
225+
self::assertEquals(
226+
'',
227+
$this->formatter->formatViolations(
228+
$this->createSniff()->withViolations([])->getViolations()
229+
)
230+
);
231+
}
232+
167233
protected function setUp(): void
168234
{
169235
$this->formatter = new MarkdownFormatter();

tests/Generator/JekyllPageGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use App\Value\Violation;
1313
use PHPUnit\Framework\TestCase;
1414

15-
/** @covers \App\Generator\JekyllPage */
15+
/** @covers \App\Generator\JekyllPageGenerator */
1616
class JekyllPageGeneratorTest extends TestCase
1717
{
1818
private JekyllPageGenerator $generator;

0 commit comments

Comments
 (0)