Skip to content

Commit 3ba1aff

Browse files
authored
Generic/DisallowShortOpenTag: improve code coverage (#638)
* Add extra tests to improve code coverage * Add comment to last test in case file 3 to clarify that it must be the last in the file.
1 parent 028501d commit 3ba1aff

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.3.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ Some content <?
1212
echo '<?';
1313
?> Some more content
1414

15+
// Test snippet clipping with a line that has more than 40 characters after the PHP open tag.
16+
Some content <? echo $var; ?> Some longer content to trigger snippet clipping
17+
1518
// Only recognize closing tag after opener.
19+
// The test below must be the last test in the file because there must be no PHP close tag after it.
1620
Some?> content <?
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Although not the focus of this test, this is an intentional parse error when short_open_tag is on.
2+
// This should be the only test in this file.
3+
// Test that the sniff bails when short_open_tag is off and there is a token other than
4+
// T_INLINE_HTML after the short open tag and before the close tag.
5+
6+
<?<?php

src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ protected function getTestFiles($testFileBase)
3636
$testFiles[] = $testFileBase.'2.inc';
3737
} else {
3838
$testFiles[] = $testFileBase.'3.inc';
39+
$testFiles[] = $testFileBase.'4.inc';
3940
}
4041

4142
return $testFiles;
@@ -97,6 +98,7 @@ public function getWarningList($testFile='')
9798
3 => 1,
9899
6 => 1,
99100
11 => 1,
101+
16 => 1,
100102
];
101103
default:
102104
return [];

0 commit comments

Comments
 (0)