Completed
Push — master ( b52690...50932b )
by Wim
02:29
created

dataNewIniDirectivesWithAlternative()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * New ini directives sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * New ini directives sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class NewIniDirectivesSniffTest extends BaseSniffTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    /**
19
     * Test functions that shouldnt be flagged by this sniff
20
     *
21
     * @return void
22
     */
23
    public function testFunctionThatShouldntBeFlagged()
24
    {
25
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
26
27
        $this->assertNoViolation($file, 3);
28
        $this->assertNoViolation($file, 4);
29
        $this->assertNoViolation($file, 5);
30
    }
31
32
    /**
33
     * Test allow_url_include
34
     *
35
     * @return void
36
     */
37
    public function testAllowUrlInclude()
38
    {
39
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
40
41
        $this->assertWarning($file, 7, "INI directive 'allow_url_include' is not available before version 5.2");
42
        $this->assertWarning($file, 8, "INI directive 'allow_url_include' is not available before version 5.2");
43
44
        // Line 9 tests using double quotes
45
        $this->assertWarning($file, 9, "INI directive 'allow_url_include' is not available before version 5.2");
46
    }
47
48
    /**
49
     * testPcreBacktracLimit
50
     *
51
     * @return void
52
     */
53
    public function testPcreBacktrackLimit()
54
    {
55
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
56
57
        $this->assertWarning($file, 11, "INI directive 'pcre.backtrack_limit' is not available before version 5.2");
58
        $this->assertWarning($file, 12, "INI directive 'pcre.backtrack_limit' is not available before version 5.2");
59
    }
60
61
    /**
62
     * testPcreRecursionLimit
63
     *
64
     * @return void
65
     */
66
    public function testPcreRecursionLimit()
67
    {
68
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
69
70
        $this->assertWarning($file, 14, "INI directive 'pcre.recursion_limit' is not available before version 5.2");
71
        $this->assertWarning($file, 15, "INI directive 'pcre.recursion_limit' is not available before version 5.2");
72
    }
73
74
    /**
75
     * testSessionCookieHttpOnly
76
     *
77
     * @return void
78
     */
79
    public function testSessionCookieHttpOnly()
80
    {
81
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.1');
82
83
        $this->assertWarning($file, 17, "INI directive 'session.cookie_httponly' is not available before version 5.2");
84
        $this->assertWarning($file, 18, "INI directive 'session.cookie_httponly' is not available before version 5.2");
85
    }
86
87
    /**
88
     * testMaxInputNestingLevel
89
     *
90
     * @return void
91
     */
92 View Code Duplication
    public function testMaxInputNestingLevel()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
107
     *
108
     * @return void
109
     */
110
    public function testUserIniFilename()
111
    {
112
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
113
114
        $this->assertWarning($file, 23, "INI directive 'user_ini.filename' is not available before version 5.3");
115
        $this->assertWarning($file, 24, "INI directive 'user_ini.filename' is not available before version 5.3");
116
    }
117
118
    /**
119
     * testUserInitCacheTtl
120
     *
121
     * @return void
122
     */
123
    public function testUserInitCacheTtl()
124
    {
125
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
126
127
        $this->assertWarning($file, 26, "INI directive 'user_ini.cache_ttl' is not available before version 5.3");
128
        $this->assertWarning($file, 27, "INI directive 'user_ini.cache_ttl' is not available before version 5.3");
129
    }
130
131
    /**
132
     * testExitOnTimeout
133
     *
134
     * @return void
135
     */
136
    public function testExitOnTimeout()
137
    {
138
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
139
140
        $this->assertWarning($file, 29, "INI directive 'exit_on_timeout' is not available before version 5.3");
141
        $this->assertWarning($file, 30, "INI directive 'exit_on_timeout' is not available before version 5.3");
142
    }
143
144
    /**
145
     * testMbstringHttpOutputConvMimetype
146
     *
147
     * @return void
148
     */
149
    public function testMbstringHttpOutputConvMimetype()
150
    {
151
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
152
153
        $this->assertWarning($file, 32, "INI directive 'mbstring.http_output_conv_mimetype' is not available before version 5.3");
154
        $this->assertWarning($file, 33, "INI directive 'mbstring.http_output_conv_mimetype' is not available before version 5.3");
155
    }
156
157
    /**
158
     * testRequestOrder
159
     *
160
     * @return void
161
     */
162
    public function testRequestOrder()
163
    {
164
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
165
166
        $this->assertWarning($file, 35, "INI directive 'request_order' is not available before version 5.3");
167
        $this->assertWarning($file, 36, "INI directive 'request_order' is not available before version 5.3");
168
    }
169
170
    /**
171
     * testCliPager
172
     *
173
     * @return void
174
     */
175
    public function testCliPager()
176
    {
177
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
178
179
        $this->assertWarning($file, 38, "INI directive 'cli.pager' is not available before version 5.4");
180
        $this->assertWarning($file, 39, "INI directive 'cli.pager' is not available before version 5.4");
181
    }
182
183
    /**
184
     * testCliPrompt
185
     *
186
     * @return void
187
     */
188
    public function testCliPrompt()
189
    {
190
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
191
192
        $this->assertWarning($file, 41, "INI directive 'cli.prompt' is not available before version 5.4");
193
        $this->assertWarning($file, 42, "INI directive 'cli.prompt' is not available before version 5.4");
194
    }
195
196
    /**
197
     * testCliServerColor
198
     *
199
     * @return void
200
     */
201
    public function testCliServerColor()
202
    {
203
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
204
205
        $this->assertWarning($file, 44, "INI directive 'cli_server.color' is not available before version 5.4");
206
        $this->assertWarning($file, 45, "INI directive 'cli_server.color' is not available before version 5.4");
207
    }
208
209
    /**
210
     * testMaxInputVars
211
     *
212
     * @return void
213
     */
214
    public function testMaxInputVars()
215
    {
216
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.2');
217
218
        $this->assertWarning($file, 47, "INI directive 'max_input_vars' is not available before version 5.3.9");
219
        $this->assertWarning($file, 48, "INI directive 'max_input_vars' is not available before version 5.3.9");
220
    }
221
222
    /**
223
     * testZendMultibyte
224
     *
225
     * @return void
226
     */
227
    public function testZendMultibyte()
228
    {
229
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
230
231
        $this->assertWarning($file, 50, "INI directive 'zend.multibyte' is not available before version 5.4");
232
        $this->assertWarning($file, 51, "INI directive 'zend.multibyte' is not available before version 5.4");
233
    }
234
235
    /**
236
     * testZendScriptEncoding
237
     *
238
     * @return void
239
     */
240
    public function testZendScriptEncoding()
241
    {
242
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
243
244
        $this->assertWarning($file, 53, "INI directive 'zend.script_encoding' is not available before version 5.4");
245
        $this->assertWarning($file, 54, "INI directive 'zend.script_encoding' is not available before version 5.4");
246
    }
247
248
    /**
249
     * testZendSignalCheck
250
     *
251
     * @return void
252
     */
253
    public function testZendSignalCheck()
254
    {
255
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
256
257
        $this->assertWarning($file, 56, "INI directive 'zend.signal_check' is not available before version 5.4");
258
        $this->assertWarning($file, 57, "INI directive 'zend.signal_check' is not available before version 5.4");
259
    }
260
261
    /**
262
     * testSessionUploadProgressEnabled
263
     *
264
     * @return void
265
     */
266
    public function testSessionUploadProgressEnabled()
267
    {
268
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
269
270
        $this->assertWarning($file, 59, "INI directive 'session.upload_progress.enabled' is not available before version 5.4");
271
        $this->assertWarning($file, 60, "INI directive 'session.upload_progress.enabled' is not available before version 5.4");
272
    }
273
274
    /**
275
     * testSessionUploadProgressCleanup
276
     *
277
     * @return void
278
     */
279
    public function testSessionUploadProgressCleanup()
280
    {
281
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
282
283
        $this->assertWarning($file, 62, "INI directive 'session.upload_progress.cleanup' is not available before version 5.4");
284
        $this->assertWarning($file, 63, "INI directive 'session.upload_progress.cleanup' is not available before version 5.4");
285
    }
286
287
    /**
288
     * testSessionUploadProgressName
289
     *
290
     * @return void
291
     */
292
    public function testSessionUploadProgressName()
293
    {
294
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
295
296
        $this->assertWarning($file, 65, "INI directive 'session.upload_progress.name' is not available before version 5.4");
297
        $this->assertWarning($file, 66, "INI directive 'session.upload_progress.name' is not available before version 5.4");
298
    }
299
300
    /**
301
     * testSessionUploadProgressFreq
302
     *
303
     * @return void
304
     */
305
    public function testSessionUploadProgressFreq()
306
    {
307
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
308
309
        $this->assertWarning($file, 68, "INI directive 'session.upload_progress.freq' is not available before version 5.4");
310
        $this->assertWarning($file, 69, "INI directive 'session.upload_progress.freq' is not available before version 5.4");
311
    }
312
313
    /**
314
     * testEnablePostDataReading
315
     *
316
     * @return void
317
     */
318
    public function testEnablePostDataReading()
319
    {
320
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
321
322
        $this->assertWarning($file, 71, "INI directive 'enable_post_data_reading' is not available before version 5.4");
323
        $this->assertWarning($file, 72, "INI directive 'enable_post_data_reading' is not available before version 5.4");
324
    }
325
326
    /**
327
     * testWindowsShowCrtWarning
328
     *
329
     * @return void
330
     */
331
    public function testWindowsShowCrtWarning()
332
    {
333
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.3');
334
335
        $this->assertWarning($file, 74, "INI directive 'windows_show_crt_warning' is not available before version 5.4");
336
        $this->assertWarning($file, 75, "INI directive 'windows_show_crt_warning' is not available before version 5.4");
337
    }
338
339
    /**
340
     * testIntlUseExceptions
341
     *
342
     * @return void
343
     */
344
    public function testIntlUseExceptions()
345
    {
346
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.4');
347
348
        $this->assertWarning($file, 77, "INI directive 'intl.use_exceptions' is not available before version 5.5");
349
        $this->assertWarning($file, 78, "INI directive 'intl.use_exceptions' is not available before version 5.5");
350
    }
351
352
    /**
353
     * testMysqlndSha256ServerPublicKey
354
     *
355
     * @return void
356
     */
357
    public function testMysqlndSha256ServerPublicKey()
358
    {
359
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', '5.4');
360
361
        $this->assertWarning($file, 80, "INI directive 'mysqlnd.sha256_server_public_key' is not available before version 5.5");
362
        $this->assertWarning($file, 81, "INI directive 'mysqlnd.sha256_server_public_key' is not available before version 5.5");
363
    }
364
365
366
    /**
367
     * testNewIniDirectives
368
     *
369
     * @dataProvider dataNewIniDirectives
370
     *
371
     * @return void
372
     */
373 View Code Duplication
    public function testNewIniDirectives($iniName, $fromVersion, $lines, $warningVersion, $okVersion)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
374
    {
375
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', $warningVersion);
376
        foreach($lines as $line) {
377
            $this->assertWarning($file, $line, "INI directive '{$iniName}' is not available before version $fromVersion");
378
        }
379
380
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', $okVersion);
381
        foreach( $lines as $line ) {
382
            $this->assertNoViolation($file, $line);
383
        }
384
    }
385
386
    public function dataNewIniDirectives() {
387
        return array(
388
            array('auto_globals_jit', '5.0', array(83, 84), '4.4', '5.1'),
389
            array('com.code_page', '5.0', array(86, 87), '4.4', '5.1'),
390
            array('date.default_latitude', '5.0', array(89, 90), '4.4', '5.1'),
391
            array('date.default_longitude', '5.0', array(92, 93), '4.4', '5.1'),
392
            array('date.sunrise_zenith', '5.0', array(95, 96), '4.4', '5.1'),
393
            array('date.sunset_zenith', '5.0', array(98, 99), '4.4', '5.1'),
394
            array('ibase.default_charset', '5.0', array(101, 102), '4.4', '5.1'),
395
            array('ibase.default_db', '5.0', array(104, 105), '4.4', '5.1'),
396
            array('mail.force_extra_parameters', '5.0', array(107, 108), '4.4', '5.1'),
397
            array('mime_magic.debug', '5.0', array(110, 111), '4.4', '5.1'),
398
            array('mysqli.max_links', '5.0', array(113, 114), '4.4', '5.1'),
399
            array('mysqli.default_port', '5.0', array(116, 117), '4.4', '5.1'),
400
            array('mysqli.default_socket', '5.0', array(119, 120), '4.4', '5.1'),
401
            array('mysqli.default_host', '5.0', array(122, 123), '4.4', '5.1'),
402
            array('mysqli.default_user', '5.0', array(125, 126), '4.4', '5.1'),
403
            array('mysqli.default_pw', '5.0', array(128, 129), '4.4', '5.1'),
404
            array('report_zend_debug', '5.0', array(131, 132), '4.4', '5.1'),
405
            array('session.hash_bits_per_character', '5.0', array(134, 135), '4.4', '5.1'),
406
            array('session.hash_function', '5.0', array(137, 138), '4.4', '5.1'),
407
            array('soap.wsdl_cache_dir', '5.0', array(140, 141), '4.4', '5.1'),
408
            array('soap.wsdl_cache_enabled', '5.0', array(143, 144), '4.4', '5.1'),
409
            array('soap.wsdl_cache_ttl', '5.0', array(146, 147), '4.4', '5.1'),
410
            array('sqlite.assoc_case', '5.0', array(149, 150), '4.4', '5.1'),
411
            array('tidy.clean_output', '5.0', array(152, 153), '4.4', '5.1'),
412
            array('tidy.default_config', '5.0', array(155, 156), '4.4', '5.1'),
413
            array('zend.ze1_compatibility_mode', '5.0', array(158, 159), '4.4', '5.1'),
414
415
            array('date.timezone', '5.1', array(161, 162), '5.0', '5.2'),
416
            array('detect_unicode', '5.1', array(164, 165), '5.0', '5.2'),
417
            array('realpath_cache_size', '5.1', array(170, 171), '5.0', '5.2'),
418
            array('realpath_cache_ttl', '5.1', array(173, 174), '5.0', '5.2'),
419
420
            array('mbstring.strict_detection', '5.1.2', array(176, 177), '5.1', '5.2'),
421
            array('mssql.charset', '5.1.2', array(179, 180), '5.1', '5.2'),
422
423
            array('gd.jpeg_ignore_warning', '5.1.3', array(182, 183), '5.1', '5.2'),
424
425
            array('fbsql.show_timestamp_decimals', '5.1.5', array(185, 186), '5.1', '5.2'),
426
            array('soap.wsdl_cache', '5.1.5', array(188, 189), '5.1', '5.2'),
427
            array('soap.wsdl_cache_limit', '5.1.5', array(191, 192), '5.1', '5.2'),
428
429
            array('filter.default', '5.2', array(194, 195), '5.1', '5.3'),
430
            array('filter.default_flags', '5.2', array(197, 198), '5.1', '5.3'),
431
432
            array('cgi.check_shebang_line', '5.2.1', array(200, 201), '5.2', '5.3'),
433
434
            array('mysqli.allow_local_infile', '5.2.4', array(203, 204), '5.2', '5.3'),
435
436
            array('max_file_uploads', '5.2.12', array(206, 207), '5.2', '5.3'),
437
438
            array('cgi.discard_path', '5.3', array(209, 210), '5.2', '5.4'),
439
            array('intl.default_locale', '5.3', array(212, 213), '5.2', '5.4'),
440
            array('intl.error_level', '5.3', array(215, 216), '5.2', '5.4'),
441
            array('mail.add_x_header', '5.3', array(218, 219), '5.2', '5.4'),
442
            array('mail.log', '5.3', array(221, 222), '5.2', '5.4'),
443
            array('mysqli.allow_persistent', '5.3', array(224, 225), '5.2', '5.4'),
444
            array('mysqli.max_persistent', '5.3', array(227, 228), '5.2', '5.4'),
445
            array('mysqli.cache_size', '5.3', array(230, 231), '5.2', '5.4'),
446
            array('mysqlnd.collect_memory_statistics', '5.3', array(233, 234), '5.2', '5.4'),
447
            array('mysqlnd.collect_statistics', '5.3', array(236, 237), '5.2', '5.4'),
448
            array('mysqlnd.debug', '5.3', array(239, 240), '5.2', '5.4'),
449
            array('mysqlnd.net_read_buffer_size', '5.3', array(242, 243), '5.2', '5.4'),
450
            array('odbc.default_cursortype', '5.3', array(245, 246), '5.2', '5.4'),
451
            array('zend.enable_gc', '5.3', array(248, 249), '5.2', '5.4'),
452
453
            array('curl.cainfo', '5.3.7', array(251, 252), '5.3', '5.4'),
454
455
            array('sqlite3.extension_dir', '5.3.11', array(254, 255), '5.3', '5.4'),
456
457
            array('session.upload_progress.prefix', '5.4', array(257, 258), '5.3', '5.5'),
458
            array('mysqlnd.log_mask', '5.4', array(263, 264), '5.3', '5.5'),
459
            array('mysqlnd.mempool_default_size', '5.4', array(266, 267), '5.3', '5.5'),
460
            array('mysqlnd.net_cmd_buffer_size', '5.4', array(269, 270), '5.3', '5.5'),
461
            array('mysqlnd.net_read_timeout', '5.4', array(272, 273), '5.3', '5.5'),
462
            array('phar.cache_list', '5.4', array(275, 276), '5.3', '5.5'),
463
464
            array('mysqlnd.trace_alloc', '5.5', array(278, 279), '5.4', '5.6'),
465
            array('sys_temp_dir', '5.5', array(281, 282), '5.4', '5.6'),
466
            array('xsl.security_prefs', '5.5', array(284, 285), '5.4', '5.6'),
467
468
            array('session.use_strict_mode', '5.5.2', array(287, 288), '5.5', '5.6'),
469
470
            array('mysqli.rollback_on_cached_plink', '5.6', array(290, 291), '5.5', '7.0'),
471
472
            array('assert.exception', '7.0', array(293, 294), '5.6', '7.1'),
473
            array('pcre.jit', '7.0', array(296, 297), '5.6', '7.1'),
474
            array('session.lazy_write', '7.0', array(299, 300), '5.6', '7.1'),
475
            array('zend.assertions', '7.0', array(302, 303), '5.6', '7.1'),
476
477
        );
478
    }
479
480
481
    /**
482
     * testNewIniDirectivesWithAlternative
483
     *
484
     * @dataProvider dataNewIniDirectivesWithAlternative
485
     *
486
     * @return void
487
     */
488 View Code Duplication
    public function testNewIniDirectivesWithAlternative($iniName, $fromVersion, $alternative, $lines, $warningVersion, $okVersion)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
489
    {
490
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', $warningVersion);
491
        foreach($lines as $line) {
492
            $this->assertWarning($file, $line, "INI directive '{$iniName}' is not available before version $fromVersion");
493
        }
494
495
        $file = $this->sniffFile('sniff-examples/new_ini_directives.php', $okVersion);
496
        foreach($lines as $line) {
497
            $this->assertNoViolation($file, $line);
498
        }
499
    }
500
501
    public function dataNewIniDirectivesWithAlternative() {
502
        return array(
503
            array('fbsql.batchsize', '5.1', 'fbsql.batchSize', array(167, 168), '5.0', '5.2'),
504
            array('zend.detect_unicode', '5.4', 'detect_unicode', array(260, 261), '5.3', '5.5'),
505
        );
506
    }
507
508
}
509