Skip to content

Commit da4960c

Browse files
committed
BadFunctions/NoEvals: add unit tests
1 parent 0dacd0d commit da4960c

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
eval('$var = file_get_contents(\'filename.php\');');
4+
eval($string);
5+
eval("\$var = file_get_contents($filename);');
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Unit test class for the NoEvals sniff.
4+
*/
5+
6+
namespace PHPCS_SecurityAudit\Security\Tests\BadFunctions;
7+
8+
use PHPCS_SecurityAudit\Security\Tests\AbstractSecurityTestCase;
9+
10+
class NoEvalsUnitTest extends AbstractSecurityTestCase
11+
{
12+
13+
/**
14+
* Returns the lines where errors should occur.
15+
*
16+
* The key of the array should represent the line number and the value
17+
* should represent the number of errors that should occur on that line.
18+
*
19+
* @return array<int, int>
20+
*/
21+
public function getErrorList()
22+
{
23+
return [
24+
3 => 1,
25+
4 => 1,
26+
5 => 1,
27+
];
28+
}
29+
30+
/**
31+
* Returns the lines where warnings should occur.
32+
*
33+
* The key of the array should represent the line number and the value
34+
* should represent the number of warnings that should occur on that line.
35+
*
36+
* @return array<int, int>
37+
*/
38+
public function getWarningList()
39+
{
40+
return [];
41+
}
42+
}

0 commit comments

Comments
 (0)