Completed
Pull Request — master (#176)
by Juliette
02:44
created

dataLateStaticBinding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * Late static binding sniff test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Late static binding sniff test file
11
 *
12
 * @uses    BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author  Juliette Reinders Folmer <[email protected]>
15
 */
16
class LateStaticBindingSniffTest 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
    const TEST_FILE = 'sniff-examples/late_static_binding.php';
19
20
    /**
21
     * testLateStaticBinding
22
     *
23
     * @group lateStaticBinding
24
     *
25
     * @dataProvider dataLateStaticBinding
26
     *
27
     * @param int $line The line number.
28
     *
29
     * @return void
30
     */
31 View Code Duplication
    public function testLateStaticBinding($line)
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...
32
    {
33
        $file = $this->sniffFile(self::TEST_FILE, '5.2');
34
        $this->assertError($file, $line, 'Late static binding is not supported in PHP 5.2 or earlier.');
35
36
        $file = $this->sniffFile(self::TEST_FILE, '5.3');
37
        $this->assertNoViolation($file, $line);
38
    }
39
40
    /**
41
     * Data provider.
42
     *
43
     * @see testLateStaticBinding()
44
     *
45
     * @return array
46
     */
47
    public function dataLateStaticBinding()
48
    {
49
        return array(
50
            array(8),
51
            array(9),
52
        );
53
    }
54
55
56
    /**
57
     * testLateStaticBindingOutsideClassScope
58
     *
59
     * @group lateStaticBinding
60
     *
61
     * @dataProvider dataLateStaticBindingOutsideClassScope
62
     *
63
     * @param int $line The line number.
64
     *
65
     * @return void
66
     */
67
    public function testLateStaticBindingOutsideClassScope($line)
68
    {
69
        $file = $this->sniffFile(self::TEST_FILE);
70
        $this->assertError($file, $line, 'Late static binding is not supported outside of class scope.');
71
    }
72
73
    /**
74
     * Data provider.
75
     *
76
     * @see testLateStaticBindingOutsideClassScope()
77
     *
78
     * @return array
79
     */
80
    public function dataLateStaticBindingOutsideClassScope()
81
    {
82
        return array(
83
            array(19),
84
        );
85
    }
86
87
88
    /**
89
     * testNoViolation
90
     *
91
     * @group lateStaticBinding
92
     *
93
     * @dataProvider dataNoViolation
94
     *
95
     * @param int $line The line number.
96
     *
97
     * @return void
98
     */
99
    public function testNoViolation($line)
100
    {
101
        $file = $this->sniffFile(self::TEST_FILE, '5.2');
102
        $this->assertNoViolation($file, $line);
103
    }
104
105
    /**
106
     * Data provider.
107
     *
108
     * @see testNoViolation()
109
     *
110
     * @return array
111
     */
112 View Code Duplication
    public function dataNoViolation()
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...
113
    {
114
        return array(
115
            array(7),
116
            array(12),
117
            array(15),
118
            array(16),
119
        );
120
    }
121
}
122