forked from WordPress/WordPress-Coding-Standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestrictedFunctionsUnitTest.php
More file actions
127 lines (112 loc) · 2.53 KB
/
RestrictedFunctionsUnitTest.php
File metadata and controls
127 lines (112 loc) · 2.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Unit test class for WordPress Coding Standard.
*
* @package WPCS\WordPressCodingStandards
* @link https://github.com/WordPress/WordPress-Coding-Standards
* @license https://opensource.org/licenses/MIT MIT
*/
namespace WordPressCS\WordPress\Tests\DB;
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
use WordPressCS\WordPress\AbstractFunctionRestrictionsSniff;
/**
* Unit test class for the DB_RestrictedFunctions sniff.
*
* @since 0.10.0
* @since 0.13.0 Class name changed: this class is now namespaced.
*
* @covers \WordPressCS\WordPress\AbstractFunctionRestrictionsSniff
* @covers \WordPressCS\WordPress\Sniffs\DB\RestrictedFunctionsSniff
*/
final class RestrictedFunctionsUnitTest extends AbstractSniffUnitTest {
/**
* Add a number of extra restricted functions to unit test the abstract
* AbstractFunctionRestrictionsSniff class.
*
* @return void
*/
protected function setUp(): void {
parent::setUp();
AbstractFunctionRestrictionsSniff::$unittest_groups = array(
'test-empty-functions-array' => array(
'type' => 'error',
'message' => 'Detected usage of %s.',
'functions' => array(),
),
'test_allow-key-handled-case-insensitively' => array(
'type' => 'error',
'message' => 'Detected usage of %s.',
'functions' => array( 'myFiction*' ),
'allow' => array( 'myFictional' => true ),
),
);
}
/**
* Reset the $groups property.
*
* @return void
*/
protected function tearDown(): void {
AbstractFunctionRestrictionsSniff::$unittest_groups = array();
parent::tearDown();
}
/**
* Returns the lines where errors should occur.
*
* @return array<int, int> Key is the line number, value is the number of expected errors.
*/
public function getErrorList() {
return array(
25 => 1,
26 => 1,
27 => 1,
28 => 1,
29 => 1,
30 => 1,
31 => 1,
32 => 1,
33 => 1,
36 => 1,
37 => 1,
38 => 1,
39 => 1,
40 => 1,
41 => 1,
42 => 1,
43 => 1,
44 => 1,
47 => 1,
48 => 1,
49 => 1,
50 => 1,
51 => 1,
54 => 1,
55 => 1,
56 => 1,
57 => 1,
60 => 1,
63 => 1,
66 => 1,
67 => 1,
68 => 1,
69 => 1,
70 => 1,
71 => 1,
72 => 1,
73 => 1,
74 => 1,
75 => 1,
76 => 1,
94 => 1,
101 => 1,
);
}
/**
* Returns the lines where warnings should occur.
*
* @return array<int, int> Key is the line number, value is the number of expected warnings.
*/
public function getWarningList() {
return array();
}
}