Code Duplication    Length = 10-13 lines in 21 locations

Tests/Sniffs/PHP/ConstantArraysUsingDefineSniffTest.php 1 location

@@ 23-34 (lines=12) @@
20
     *
21
     * @return void
22
     */
23
    public function testConstantArraysUsingDefine()
24
    {
25
        $file = $this->sniffFile('sniff-examples/constant_arrays_using_define.php', '7.0');
26
        $this->assertNoViolation($file, 3);
27
        $this->assertNoViolation($file, 9);
28
        $this->assertNoViolation($file, 15);
29
        
30
        $file = $this->sniffFile('sniff-examples/constant_arrays_using_define.php', '5.6');
31
        $this->assertError($file, 3, "Constant arrays using define are not allowed in PHP 5.6 or earlier");
32
        $this->assertError($file, 9, "Constant arrays using define are not allowed in PHP 5.6 or earlier");
33
        $this->assertNoViolation($file, 15);
34
    }
35
}
36

Tests/Sniffs/PHP/DeprecatedIniDirectivesSniffTest.php 17 locations

@@ 23-32 (lines=10) @@
20
     *
21
     * @return void
22
     */
23
    public function testDefineSyslogVariables()
24
    {
25
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
26
        $this->assertWarning($file, 3, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3");
27
        $this->assertWarning($file, 4, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3");
28
29
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
30
        $this->assertError($file, 3, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
31
        $this->assertWarning($file, 4, "INI directive 'define_syslog_variables' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
32
    }
33
34
    /**
35
     * Test register_globals
@@ 39-48 (lines=10) @@
36
     *
37
     * @return void
38
     */
39
    public function testRegisterGlobals()
40
    {
41
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
42
        $this->assertWarning($file, 6, "INI directive 'register_globals' is deprecated from PHP 5.3");
43
        $this->assertWarning($file, 7, "INI directive 'register_globals' is deprecated from PHP 5.3");
44
45
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
46
        $this->assertError($file, 6, "INI directive 'register_globals' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
47
        $this->assertWarning($file, 7, "INI directive 'register_globals' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
48
    }
49
50
    /**
51
     * Test register_long_arrays
@@ 55-64 (lines=10) @@
52
     *
53
     * @return void
54
     */
55
    public function testRegisterLongArrays()
56
    {
57
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
58
        $this->assertWarning($file, 9, "INI directive 'register_long_arrays' is deprecated from PHP 5.3");
59
        $this->assertWarning($file, 10, "INI directive 'register_long_arrays' is deprecated from PHP 5.3");
60
61
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
62
        $this->assertError($file, 9, "INI directive 'register_long_arrays' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
63
        $this->assertWarning($file, 10, "INI directive 'register_long_arrays' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
64
    }
65
66
    /**
67
     * Test magic_quotes_gpc
@@ 71-80 (lines=10) @@
68
     *
69
     * @return void
70
     */
71
    public function testMagicQuotesGpc()
72
    {
73
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
74
        $this->assertWarning($file, 12, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3");
75
        $this->assertWarning($file, 13, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3");
76
77
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
78
        $this->assertError($file, 12, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
79
        $this->assertWarning($file, 13, "INI directive 'magic_quotes_gpc' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
80
    }
81
82
    /**
83
     * Test magic_quotes_runtime
@@ 87-96 (lines=10) @@
84
     *
85
     * @return void
86
     */
87
    public function testMagicQuotesRuntime()
88
    {
89
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
90
        $this->assertWarning($file, 15, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3");
91
        $this->assertWarning($file, 16, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3");
92
93
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
94
        $this->assertError($file, 15, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
95
        $this->assertWarning($file, 16, "INI directive 'magic_quotes_runtime' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
96
    }
97
98
    /**
99
     * Test magic_quotes_sybase
@@ 103-112 (lines=10) @@
100
     *
101
     * @return void
102
     */
103
    public function testMagicQuotesSybase()
104
    {
105
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
106
        $this->assertWarning($file, 18, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3");
107
        $this->assertWarning($file, 19, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3");
108
109
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
110
        $this->assertError($file, 18, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
111
        $this->assertWarning($file, 19, "INI directive 'magic_quotes_sybase' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
112
    }
113
114
    /**
115
     * Test allow_call_time_pass_reference
@@ 119-128 (lines=10) @@
116
     *
117
     * @return void
118
     */
119
    public function testAllowCallTimePassReference()
120
    {
121
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
122
        $this->assertWarning($file, 21, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3");
123
        $this->assertWarning($file, 22, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3");
124
125
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
126
        $this->assertError($file, 21, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
127
        $this->assertWarning($file, 22, "INI directive 'allow_call_time_pass_reference' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
128
    }
129
130
    /**
131
     * Test highlight.bg
@@ 135-144 (lines=10) @@
132
     *
133
     * @return void
134
     */
135
    public function testHighlightBg()
136
    {
137
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
138
        $this->assertWarning($file, 24, "INI directive 'highlight.bg' is deprecated from PHP 5.3");
139
        $this->assertWarning($file, 25, "INI directive 'highlight.bg' is deprecated from PHP 5.3");
140
141
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
142
        $this->assertError($file, 24, "INI directive 'highlight.bg' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
143
        $this->assertWarning($file, 25, "INI directive 'highlight.bg' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
144
    }
145
146
    /**
147
     * Test session.bug_compat_42
@@ 151-160 (lines=10) @@
148
     *
149
     * @return void
150
     */
151
    public function testSessionBugCompat42()
152
    {
153
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
154
        $this->assertWarning($file, 27, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3");
155
        $this->assertWarning($file, 28, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3");
156
157
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
158
        $this->assertError($file, 27, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
159
        $this->assertWarning($file, 28, "INI directive 'session.bug_compat_42' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
160
    }
161
162
    /**
163
     * Test session.bug_compat_warn
@@ 167-176 (lines=10) @@
164
     *
165
     * @return void
166
     */
167
    public function testSessionBugCompatWarn()
168
    {
169
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
170
        $this->assertWarning($file, 30, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3");
171
        $this->assertWarning($file, 31, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3");
172
173
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
174
        $this->assertError($file, 30, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
175
        $this->assertWarning($file, 31, "INI directive 'session.bug_compat_warn' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
176
    }
177
178
    /**
179
     * Test y2k_compliance
@@ 183-192 (lines=10) @@
180
     *
181
     * @return void
182
     */
183
    public function testY2kCompliance()
184
    {
185
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
186
        $this->assertWarning($file, 33, "INI directive 'y2k_compliance' is deprecated from PHP 5.3");
187
        $this->assertWarning($file, 34, "INI directive 'y2k_compliance' is deprecated from PHP 5.3");
188
189
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
190
        $this->assertError($file, 33, "INI directive 'y2k_compliance' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
191
        $this->assertWarning($file, 34, "INI directive 'y2k_compliance' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
192
    }
193
194
    /**
195
     * Test zend.ze1_compatibility_mode
@@ 211-220 (lines=10) @@
208
     *
209
     * @return void
210
     */
211
    public function testSafeMode()
212
    {
213
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
214
        $this->assertWarning($file, 39, "INI directive 'safe_mode' is deprecated from PHP 5.3");
215
        $this->assertWarning($file, 40, "INI directive 'safe_mode' is deprecated from PHP 5.3");
216
217
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
218
        $this->assertError($file, 39, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
219
        $this->assertWarning($file, 40, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
220
    }
221
222
    /**
223
     * Test safe_mode_gid
@@ 227-236 (lines=10) @@
224
     *
225
     * @return void
226
     */
227
    public function testSafeModeGid()
228
    {
229
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
230
        $this->assertWarning($file, 42, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3");
231
        $this->assertWarning($file, 43, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3");
232
233
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
234
        $this->assertError($file, 42, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
235
        $this->assertWarning($file, 43, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
236
    }
237
238
    /**
239
     * Test safe_mode_include_dir
@@ 243-252 (lines=10) @@
240
     *
241
     * @return void
242
     */
243
    public function testSafeModeIncludeDir()
244
    {
245
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
246
        $this->assertWarning($file, 45, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3");
247
        $this->assertWarning($file, 46, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3");
248
249
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
250
        $this->assertError($file, 45, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
251
        $this->assertWarning($file, 46, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
252
    }
253
254
    /**
255
     * Test safe_mode_exec_dir
@@ 259-268 (lines=10) @@
256
     *
257
     * @return void
258
     */
259
    public function testSafeModeExecDir()
260
    {
261
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
262
        $this->assertWarning($file, 48, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3");
263
        $this->assertWarning($file, 49, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3");
264
265
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
266
        $this->assertError($file, 48, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
267
        $this->assertWarning($file, 49, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
268
    }
269
270
    /**
271
     * Test safe_mode_allowed_env_vars
@@ 275-284 (lines=10) @@
272
     *
273
     * @return void
274
     */
275
    public function testSafeModeAllowedEnvVars()
276
    {
277
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
278
        $this->assertWarning($file, 51, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3");
279
        $this->assertWarning($file, 52, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3");
280
281
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
282
        $this->assertError($file, 51, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
283
        $this->assertWarning($file, 52, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
284
    }
285
286
    /**
287
     * Test safe_mode_protected_env_vars
@@ 291-300 (lines=10) @@
288
     *
289
     * @return void
290
     */
291
    public function testSafeModeProtectedEnvVars()
292
    {
293
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
294
        $this->assertWarning($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3");
295
        $this->assertWarning($file, 55, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3");
296
297
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
298
        $this->assertError($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
299
        $this->assertWarning($file, 55, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
300
    }
301
302
    /**
303
     * Test valid directive

Tests/Sniffs/PHP/NewIniDirectivesSniffTest.php 1 location

@@ 92-103 (lines=12) @@
89
     *
90
     * @return void
91
     */
92
    public function testMaxInputNestingLevel()
93
    {
94
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
95
96
        $this->assertWarning($file, 20, "INI directive 'max_input_nesting_level' is not available before version 5.2.3");
97
        $this->assertWarning($file, 21, "INI directive 'max_input_nesting_level' is not available before version 5.2.3");
98
99
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
100
101
        $this->assertWarning($file, 20, "INI directive 'max_input_nesting_level' is not available before version 5.2.3");
102
        $this->assertWarning($file, 21, "INI directive 'max_input_nesting_level' is not available before version 5.2.3");
103
    }
104
105
    /**
106
     * testUserIniFilename

Tests/Sniffs/PHP/RemovedExtensionsSniffTest.php 1 location

@@ 205-217 (lines=13) @@
202
     *
203
     * @return void
204
     */
205
    public function testMysql()
206
    {
207
        $this->assertNoViolation($this->_sniffFile, 67);
208
209
        $file = $this->sniffFile('sniff-examples/removed_extensions.php', '5.4');
210
        $this->assertNoViolation($file, 38);
211
212
        $file = $this->sniffFile('sniff-examples/removed_extensions.php', '5.5');
213
        $this->assertWarning($file, 38, "Extension 'mysql_' is deprecated since PHP 5.5");
214
215
        $file = $this->sniffFile('sniff-examples/removed_extensions.php', '7.0');
216
        $this->assertError($file, 38, "Extension 'mysql_' is deprecated since PHP 5.5 and removed since PHP 7.0");
217
    }
218
219
    /**
220
     * testNcurses

Tests/Sniffs/PHP/NewClassesSniffTest.php 1 location

@@ 30-41 (lines=12) @@
27
     *
28
     * @return void
29
     */
30
    public function testDateTime()
31
    {
32
        $file = $this->sniffFile('sniff-examples/new_classes.php', '5.1');
33
        $this->assertError($file, 3, "The built-in class DateTime is not present in PHP version 5.1 or earlier");
34
        $this->assertError($file, 43, "The built-in class DateTime is not present in PHP version 5.1 or earlier");
35
        $this->assertError($file, 45, "The built-in class DateTime is not present in PHP version 5.1 or earlier");
36
37
        $file = $this->sniffFile('sniff-examples/new_classes.php', '5.2');
38
        $this->assertNoViolation($file, 3);
39
        $this->assertNoViolation($file, 43);
40
        $this->assertNoViolation($file, 45);
41
    }
42
43
    /**
44
     * Test date time zone