Code Duplication    Length = 10-13 lines in 31 locations

Tests/Sniffs/PHP/DeprecatedIniDirectivesSniffTest.php 26 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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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->assertError($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
@@ 199-208 (lines=10) @@
196
     *
197
     * @return void
198
     */
199
    public function testZendZe1CompatibilityMode()
200
    {
201
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
202
        $this->assertWarning($file, 36, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3");
203
        $this->assertWarning($file, 37, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3");
204
        
205
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
206
        $this->assertError($file, 36, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
207
        $this->assertError($file, 37, "INI directive 'zend.ze1_compatibility_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
208
    }
209
210
    /**
211
     * Test safe_mode
@@ 215-224 (lines=10) @@
212
     *
213
     * @return void
214
     */
215
    public function testSafeMode()
216
    {
217
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
218
        $this->assertWarning($file, 39, "INI directive 'safe_mode' is deprecated from PHP 5.3");
219
        $this->assertWarning($file, 40, "INI directive 'safe_mode' is deprecated from PHP 5.3");
220
        
221
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
222
        $this->assertError($file, 39, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
223
        $this->assertError($file, 40, "INI directive 'safe_mode' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
224
    }
225
226
    /**
227
     * Test safe_mode_gid
@@ 231-240 (lines=10) @@
228
     *
229
     * @return void
230
     */
231
    public function testSafeModeGid()
232
    {
233
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
234
        $this->assertWarning($file, 42, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3");
235
        $this->assertWarning($file, 43, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3");
236
        
237
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
238
        $this->assertError($file, 42, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
239
        $this->assertError($file, 43, "INI directive 'safe_mode_gid' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
240
    }
241
242
    /**
243
     * Test safe_mode_include_dir
@@ 247-256 (lines=10) @@
244
     *
245
     * @return void
246
     */
247
    public function testSafeModeIncludeDir()
248
    {
249
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
250
        $this->assertWarning($file, 45, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3");
251
        $this->assertWarning($file, 46, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3");
252
        
253
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
254
        $this->assertError($file, 45, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
255
        $this->assertError($file, 46, "INI directive 'safe_mode_include_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
256
    }
257
258
    /**
259
     * Test safe_mode_exec_dir
@@ 263-272 (lines=10) @@
260
     *
261
     * @return void
262
     */
263
    public function testSafeModeExecDir()
264
    {
265
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
266
        $this->assertWarning($file, 48, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3");
267
        $this->assertWarning($file, 49, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3");
268
        
269
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
270
        $this->assertError($file, 48, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
271
        $this->assertError($file, 49, "INI directive 'safe_mode_exec_dir' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
272
    }
273
274
    /**
275
     * Test safe_mode_allowed_env_vars
@@ 279-288 (lines=10) @@
276
     *
277
     * @return void
278
     */
279
    public function testSafeModeAllowedEnvVars()
280
    {
281
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
282
        $this->assertWarning($file, 51, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3");
283
        $this->assertWarning($file, 52, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3");
284
        
285
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
286
        $this->assertError($file, 51, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
287
        $this->assertError($file, 52, "INI directive 'safe_mode_allowed_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
288
    }
289
290
    /**
291
     * Test safe_mode_protected_env_vars
@@ 295-304 (lines=10) @@
292
     *
293
     * @return void
294
     */
295
    public function testSafeModeProtectedEnvVars()
296
    {
297
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.3');
298
        $this->assertWarning($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3");
299
        $this->assertWarning($file, 55, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3");
300
        
301
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.4');
302
        $this->assertError($file, 54, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
303
        $this->assertError($file, 55, "INI directive 'safe_mode_protected_env_vars' is deprecated from PHP 5.3 and forbidden from PHP 5.4");
304
    }
305
306
    /**
307
     * Test valid directive
@@ 323-332 (lines=10) @@
320
     *
321
     * @return void
322
     */
323
    public function testIconvInputEncoding()
324
    {
325
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
326
        $this->assertNoViolation($file, 62);
327
        $this->assertNoViolation($file, 63);
328
        
329
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
330
        $this->assertWarning($file, 62, "INI directive 'iconv.input_encoding' is deprecated from PHP 5.6");
331
        $this->assertWarning($file, 63, "INI directive 'iconv.input_encoding' is deprecated from PHP 5.6");
332
    }
333
334
    /**
335
     * Test iconv.output_encoding setting
@@ 339-348 (lines=10) @@
336
     *
337
     * @return void
338
     */
339
    public function testIconvOutputEncoding()
340
    {
341
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
342
        $this->assertNoViolation($file, 65);
343
        $this->assertNoViolation($file, 66);
344
        
345
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
346
        $this->assertWarning($file, 65, "INI directive 'iconv.output_encoding' is deprecated from PHP 5.6");
347
        $this->assertWarning($file, 66, "INI directive 'iconv.output_encoding' is deprecated from PHP 5.6");
348
    }
349
    
350
    /**
351
     * Test iconv.internal_encoding setting
@@ 355-364 (lines=10) @@
352
     *
353
     * @return void
354
     */
355
    public function testIconvInternalEncoding()
356
    {
357
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
358
        $this->assertNoViolation($file, 68);
359
        $this->assertNoViolation($file, 69);
360
    
361
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
362
        $this->assertWarning($file, 68, "INI directive 'iconv.internal_encoding' is deprecated from PHP 5.6");
363
        $this->assertWarning($file, 69, "INI directive 'iconv.internal_encoding' is deprecated from PHP 5.6");
364
    }
365
    
366
    
367
    /**
@@ 372-381 (lines=10) @@
369
     *
370
     * @return void
371
     */
372
    public function testMbstringHttpInput()
373
    {
374
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
375
        $this->assertNoViolation($file, 71);
376
        $this->assertNoViolation($file, 72);
377
    
378
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
379
        $this->assertWarning($file, 71, "INI directive 'mbstring.http_input' is deprecated from PHP 5.6");
380
        $this->assertWarning($file, 72, "INI directive 'mbstring.http_input' is deprecated from PHP 5.6");
381
    }
382
    
383
    /**
384
     * Test mbstring.http_output setting
@@ 388-397 (lines=10) @@
385
     *
386
     * @return void
387
     */
388
    public function testMbstringHttpOutput()
389
    {
390
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
391
        $this->assertNoViolation($file, 74);
392
        $this->assertNoViolation($file, 75);
393
    
394
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
395
        $this->assertWarning($file, 74, "INI directive 'mbstring.http_output' is deprecated from PHP 5.6");
396
        $this->assertWarning($file, 75, "INI directive 'mbstring.http_output' is deprecated from PHP 5.6");
397
    }
398
    
399
    /**
400
     * Test mbstring.internal_encoding setting
@@ 404-413 (lines=10) @@
401
     *
402
     * @return void
403
     */
404
    public function testMbstringInternalEncoding()
405
    {
406
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.5');
407
        $this->assertNoViolation($file, 77);
408
        $this->assertNoViolation($file, 78);
409
    
410
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
411
        $this->assertWarning($file, 77, "INI directive 'mbstring.internal_encoding' is deprecated from PHP 5.6");
412
        $this->assertWarning($file, 78, "INI directive 'mbstring.internal_encoding' is deprecated from PHP 5.6");
413
    }
414
    
415
    /**
416
     * Test always_populate_raw_post_data setting
@@ 440-449 (lines=10) @@
437
     *
438
     * @return void
439
     */
440
    public function testAsptags()
441
    {
442
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
443
        $this->assertNoViolation($file, 83);
444
        $this->assertNoViolation($file, 84);
445
    
446
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '7.0');
447
        $this->assertError($file, 83, "INI directive 'asp_tags' is forbidden from PHP 7.0");
448
        $this->assertError($file, 84, "INI directive 'asp_tags' is forbidden from PHP 7.0");
449
    }
450
    
451
    /**
452
     * Test xsl.security_prefs  setting
@@ 456-465 (lines=10) @@
453
     *
454
     * @return void
455
     */
456
    public function testXslSecurityPrefs()
457
    {
458
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '5.6');
459
        $this->assertNoViolation($file, 86);
460
        $this->assertNoViolation($file, 87);
461
    
462
        $file = $this->sniffFile('sniff-examples/deprecated_ini_directives.php', '7.0');
463
        $this->assertError($file, 86, "INI directive 'xsl.security_prefs' is forbidden from PHP 7.0");
464
        $this->assertError($file, 87, "INI directive 'xsl.security_prefs' is forbidden from PHP 7.0");
465
    }
466
    
467
    
468
    public function testSettingTestVersion()

Tests/Sniffs/PHP/ForbiddenEmptyListAssignmentSniffTest.php 1 location

@@ 23-32 (lines=10) @@
20
     *
21
     * @return void
22
     */
23
    public function testEmptyListAssignment()
24
    {
25
        $file = $this->sniffFile('sniff-examples/forbidden_empty_list_assignment.php', '5.6');
26
        $this->assertNoViolation($file, 3);
27
        $this->assertNoViolation($file, 5);
28
        
29
        $file = $this->sniffFile('sniff-examples/forbidden_empty_list_assignment.php', '7.0');
30
        $this->assertError($file, 3, "Empty list() assignments are not allowed since PHP 7.0");
31
        $this->assertError($file, 5, "Empty list() assignments are not allowed since PHP 7.0");
32
    }
33
}
34

Tests/Sniffs/PHP/ForbiddenNegativeBitshiftSniffTest.php 1 location

@@ 23-32 (lines=10) @@
20
     *
21
     * @return void
22
     */
23
    public function testSettingTestVersion()
24
    {
25
        $file = $this->sniffFile('sniff-examples/forbidden_negative_bitshift.php', '5.6');
26
        $this->assertNoViolation($file, 3);
27
        $this->assertNoViolation($file, 5);
28
        
29
        $file = $this->sniffFile('sniff-examples/forbidden_negative_bitshift.php', '7.0');
30
        $this->assertError($file, 3, 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0');
31
        $this->assertNoViolation($file, 5);
32
    }
33
}
34
35

Tests/Sniffs/PHP/NewConstructsSniffTest.php 1 location

@@ 81-90 (lines=10) @@
78
     *
79
     * @return void
80
     */
81
    public function testCoalescing()
82
    {
83
        $file = $this->sniffFile('sniff-examples/new_constructs.php', '5.6');
84
        $this->assertError($file, 8, "null coalescing operator (??) is not present in PHP version 5.6 or earlier");
85
        $this->assertError($file, 10, "null coalescing operator (??) is not present in PHP version 5.6 or earlier");
86
        
87
        $file = $this->sniffFile('sniff-examples/new_constructs.php', '7.0');
88
        $this->assertNoViolation($file, 8);
89
        $this->assertNoViolation($file, 10);
90
    }
91
}
92

Tests/Sniffs/PHP/NewFunctionsSniffTest.php 1 location

@@ 23-35 (lines=13) @@
20
     *
21
     * @return void
22
     */
23
    public function testArrayFillKeys()
24
    {
25
        $file = $this->sniffFile('sniff-examples/new_functions.php', '5.1');
26
        $this->assertError($file, 3, "The function array_fill_keys is not present in PHP version 5.1 or earlier");
27
28
        // Verify that sniff doesn't throw an error in version 5.2
29
        $file = $this->sniffFile('sniff-examples/new_functions.php', '5.2');
30
        $this->assertNoViolation($file, 3);
31
32
        // Verify that sniff doesn't catch static functions called with a class
33
        $file = $this->sniffFile('sniff-examples/new_functions.php', '5.1');
34
        $this->assertNoViolation($file, 4);
35
    }
36
}
37

Tests/Sniffs/PHP/RemovedGlobalVariablesSniffTest.php 1 location

@@ 23-33 (lines=11) @@
20
     *
21
     * @return void
22
     */
23
    public function testHttpRawPostData()
24
    {
25
        $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '5.5');
26
        $this->assertNoViolation($file);
27
        
28
        $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '5.6');
29
        $this->assertWarning($file, 3, "Global variable 'HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 - use php://input instead");
30
        
31
        $file = $this->sniffFile('sniff-examples/removed_global_variables.php', '7.0');
32
        $this->assertError($file, 3, "Global variable 'HTTP_RAW_POST_DATA' is deprecated since PHP 5.6 and removed since PHP 7.0 - use php://input instead");
33
    }
34
}
35