forked from WordPress/WordPress-Coding-Standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapabilitiesUnitTest.php
More file actions
144 lines (132 loc) · 3.06 KB
/
CapabilitiesUnitTest.php
File metadata and controls
144 lines (132 loc) · 3.06 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Unit test class for WordPress Coding Standard.
*
* @package WPCS\WordPressCodingStandards
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
* @license https://opensource.org/licenses/MIT MIT
*/
namespace WordPressCS\WordPress\Tests\WP;
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
use PHPCSUtils\BackCompat\Helper;
/**
* Unit test class for the Capabilities sniff.
*
* @since 3.0.0
*
* @covers \WordPressCS\WordPress\Sniffs\WP\CapabilitiesSniff
*/
final class CapabilitiesUnitTest extends AbstractSniffUnitTest {
/**
* Adjust the config to allow for testing with specific CLI arguments.
*
* @param string $filename The name of the file being tested.
* @param \PHP_CodeSniffer\Config $config The config data for the run.
*
* @return void
*/
public function setCliValues( $filename, $config ) {
if ( 'CapabilitiesUnitTest.1.inc' === $filename ) {
$config->warningSeverity = 3;
} else {
$config->warningSeverity = 5;
}
if ( 'CapabilitiesUnitTest.2.inc' === $filename ) {
Helper::setConfigData( 'minimum_wp_version', '2.9', true, $config );
} elseif ( 'CapabilitiesUnitTest.3.inc' === $filename ) {
Helper::setConfigData( 'minimum_wp_version', '6.1', true, $config );
} else {
// Delete for other files.
Helper::setConfigData( 'minimum_wp_version', null, true, $config );
}
}
/**
* Returns the lines where errors should occur.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int> Key is the line number, value is the number of expected errors.
*/
public function getErrorList( $testFile = '' ) {
switch ( $testFile ) {
case 'CapabilitiesUnitTest.1.inc':
return array(
40 => 1,
49 => 1,
50 => 1,
65 => 1,
66 => 1,
67 => 1,
68 => 1,
69 => 1,
70 => 1,
71 => 1,
72 => 1,
73 => 1,
74 => 1,
78 => 1,
85 => 1,
106 => 1,
118 => 1,
);
case 'CapabilitiesUnitTest.3.inc':
return array(
10 => 1,
12 => 1,
14 => 1,
);
case 'CapabilitiesUnitTest.4.inc':
return array(
8 => 1,
10 => 1,
12 => 1,
);
default:
return array();
}
}
/**
* Returns the lines where warnings should occur.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int> Key is the line number, value is the number of expected warnings.
*/
public function getWarningList( $testFile = '' ) {
switch ( $testFile ) {
case 'CapabilitiesUnitTest.1.inc':
return array(
11 => 1,
12 => 1,
17 => 1,
21 => 1,
22 => 1,
23 => 1,
24 => 1,
25 => 1,
29 => 1,
31 => 1,
32 => 1,
35 => 1,
46 => 1,
55 => 1,
56 => 1,
57 => 1,
58 => 1,
59 => 1,
60 => 1,
92 => 1,
100 => 1,
105 => 1,
);
case 'CapabilitiesUnitTest.2.inc':
return array(
10 => 1,
12 => 1,
14 => 1,
);
default:
return array();
}
}
}