Skip to content

Commit 7fb9515

Browse files
authored
Merge pull request #151 from PHPCSStandards/feature/squiz-heredoc-test-tweak
Squiz/Heredoc: tweak the tests
2 parents 821b7cd + 87f52ed commit 7fb9515

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
$str = <<<EOD
3+
Example of string
4+
spanning multiple lines
5+
using heredoc syntax.
6+
EOD;
7+
8+
echo <<<'EOT'
9+
My name is "$name". I am printing some $foo->foo.
10+
Now, I am printing some {$foo->bar[1]}.
11+
This should not print a capital 'A': \x41
12+
EOT;

src/Standards/Squiz/Tests/PHP/HeredocUnitTest.inc renamed to src/Standards/Squiz/Tests/PHP/HeredocUnitTest.2.inc

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

3+
// Intentional parse error.
144
// The following function has a simulated git conflict for testing.
155
// This is not a merge conflict - it is a valid test case.
166
// Please do not remove.

src/Standards/Squiz/Tests/PHP/HeredocUnitTest.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ class HeredocUnitTest extends AbstractSniffUnitTest
2626
* The key of the array should represent the line number and the value
2727
* should represent the number of errors that should occur on that line.
2828
*
29+
* @param string $testFile The name of the file being tested.
30+
*
2931
* @return array<int, int>
3032
*/
31-
public function getErrorList()
33+
public function getErrorList($testFile='')
3234
{
33-
return [
34-
2 => 1,
35-
8 => 1,
36-
];
35+
switch ($testFile) {
36+
case 'HeredocUnitTest.1.inc':
37+
return [
38+
2 => 1,
39+
8 => 1,
40+
];
41+
42+
default:
43+
return [];
44+
}//end switch
3745

3846
}//end getErrorList()
3947

0 commit comments

Comments
 (0)