Completed
Pull Request — master (#149)
by Juliette
02:28
created

LongArraysSniffTest::testSpecificVersionTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Long Arrays Sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Long Arrays Sniff tests
11
 *
12
 * @uses BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author Jansen Price <[email protected]>
15
 */
16
class LongArraysSniffTest 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
    const TEST_FILE = 'sniff-examples/long_arrays.php';
20
21
    /**
22
     * testLongVariable
23
     *
24
     * @dataProvider dataLongVariable
25
     *
26
     * @param string $longVariable Variable name.
27
     * @param array  $lines        The line numbers in the test file which apply to this variable.
28
     * @param string $deprecatedIn The PHP version in which the variable became deprecated.
29
     * @param string $removedIn    The PHP version in which the variable was removed.
30
     * @param string $okVersion    A PHP version in which the variable was still ok to be used.
31
     *
32
     * @return void
33
     */
34 View Code Duplication
    public function testLongVariable($longVariable, $lines, $deprecatedIn, $removedIn, $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...
35
    {
36
        $file = $this->sniffFile(self::TEST_FILE);
37
        foreach ($lines as $line) {
38
            $this->assertWarning($file, $line, "The use of long predefined variables has been deprecated in {$deprecatedIn} and removed in {$removedIn}; Found '{$longVariable}'");
39
        }
40
41
        $file = $this->sniffFile(self::TEST_FILE, $okVersion);
42
        foreach ($lines as $line) {
43
            $this->assertNoViolation($file, $line);
44
        }
45
    }
46
47
    /**
48
     * Data provider.
49
     *
50
     * @see testLongVariable()
51
     *
52
     * @return array
53
     */
54
    public function dataLongVariable()
55
    {
56
        return array(
57
            array('$HTTP_POST_VARS', array(3), '5.3', '5.4', '5.2'),
58
            array('$HTTP_GET_VARS', array(4), '5.3', '5.4', '5.2'),
59
            array('$HTTP_ENV_VARS', array(5), '5.3', '5.4', '5.2'),
60
            array('$HTTP_SERVER_VARS', array(6), '5.3', '5.4', '5.2'),
61
            array('$HTTP_COOKIE_VARS', array(7), '5.3', '5.4', '5.2'),
62
            array('$HTTP_SESSION_VARS', array(8), '5.3', '5.4', '5.2'),
63
            array('$HTTP_POST_FILES', array(9), '5.3', '5.4', '5.2'),
64
        );
65
    }
66
67
}
68