Skip to content

Commit

Permalink
Generic/ByteOrderMark: improve test coverage
Browse files Browse the repository at this point in the history
This commit adds four more tests case files:
* 2 to cover the cases where the sniff is triggered but the file does not contain a BOM character.
    One of these files is in UTF-8 encoding without a BOM, the other is in ANSI/iso-8859-1 encoding.
* 2 to cover the different UTF-16 encodings with a BOM character.

Includes adding a comment to the original test case file to document the encoding (UTF-8 with BOM) of that file.
  • Loading branch information
rodrigoprimo authored and jrfnl committed Jan 26, 2024
1 parent 39b2fed commit a9642e5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.1.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php
echo 'foo';
?>
<?php
// File in UTF-8 encoding with byte order mark (BOM) character before the opening PHP tag.
echo 'foo';
?>
3 changes: 3 additions & 0 deletions src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php // File in UTF-8 encoding without a byte order mark (BOM) character before the opening PHP tag. ?>

<p>Some HTML</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Some HTML at the beginning of an ANSI/iso-8859-1 encoded file without a byte order mark (BOM) character</p>
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/Standards/Generic/Tests/Files/ByteOrderMarkUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function getErrorList($testFile='')
{
switch ($testFile) {
case 'ByteOrderMarkUnitTest.1.inc':
case 'ByteOrderMarkUnitTest.4.inc':
case 'ByteOrderMarkUnitTest.5.inc':
return [1 => 1];

default:
Expand Down

0 comments on commit a9642e5

Please sign in to comment.