-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDisallowDebugFuncCallRuleTest.php
More file actions
84 lines (79 loc) · 3.67 KB
/
DisallowDebugFuncCallRuleTest.php
File metadata and controls
84 lines (79 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
namespace CakeDC\PHPStan\Test\TestCase\Rule\Debug;
use CakeDC\PHPStan\Rule\Debug\DisallowDebugFuncCallRule;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
class DisallowDebugFuncCallRuleTest extends RuleTestCase
{
/**
* @return \PHPStan\Rules\Rule
*/
protected function getRule(): Rule
{
// getRule() method needs to return an instance of the tested rule
return new DisallowDebugFuncCallRule();
}
/**
* @return void
*/
public function testRule(): void
{
// first argument: path to the example file that contains some errors that should be reported by MyRule
// second argument: an array of expected errors,
// each error consists of the asserted error message, and the asserted error file line
$this->analyse([__DIR__ . '/Fake/FailingDebugUseLogic.php'], [
[
'Use of debug function "debug" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
14, // asserted error line
],
[
'Use of debug function "debug_print_backtrace" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
15, // asserted error line
],
[
'Use of debug function "debug_zval_dump" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
16, // asserted error line
],
[
'Use of debug function "print_r" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
19, // asserted error line
],
[
'Use of debug function "print_r" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
20, // asserted error line
],
[
'Use of debug function "var_dump" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
21, // asserted error line
],
[
'Use of debug function "var_export" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
23, // asserted error line
],
[
'Use of debug function "var_export" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
24, // asserted error line
],
[
'Use of debug function "stackTrace" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
25, // asserted error line
],
[
'Use of debug function "pr" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
26, // asserted error line
],
[
'Use of debug function "dd" is not allowed. The use in shipped code is discouraged because they can leak sensitive information or clutter output.',
28, // asserted error line
],
]);
}
/**
* @inheritDoc
*/
public static function getAdditionalConfigFiles(): array
{
return [__DIR__ . '/../../../../extension.neon'];
}
}