Skip to content

Commit 172405e

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

File tree

2 files changed

+49
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)