Skip to content

Commit

Permalink
Merge pull request PHPCSStandards#151 from PHPCSStandards/feature/squ…
Browse files Browse the repository at this point in the history
…iz-heredoc-test-tweak

Squiz/Heredoc: tweak the tests
  • Loading branch information
jrfnl authored Dec 10, 2023
2 parents 821b7cd + 87f52ed commit 7fb9515
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
12 changes: 12 additions & 0 deletions src/Standards/Squiz/Tests/PHP/HeredocUnitTest.1.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

echo <<<'EOT'
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
EOT;
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

echo <<<'EOT'
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should not print a capital 'A': \x41
EOT;

// Intentional parse error.
// The following function has a simulated git conflict for testing.
// This is not a merge conflict - it is a valid test case.
// Please do not remove.
Expand Down
18 changes: 13 additions & 5 deletions src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ class HeredocUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [
2 => 1,
8 => 1,
];
switch ($testFile) {
case 'HeredocUnitTest.1.inc':
return [
2 => 1,
8 => 1,
];

default:
return [];
}//end switch

}//end getErrorList()

Expand Down

0 comments on commit 7fb9515

Please sign in to comment.