Completed
Push — master ( 45d858...8571e4 )
by Juliette
14s
created

dataGetFunctionCallParameter()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 29
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
/**
3
 * Function parameter count test file
4
 *
5
 * @package PHPCompatibility
6
 */
7
8
9
/**
10
 * Function parameters count function tests
11
 *
12
 * @uses    BaseSniffTest
13
 * @package PHPCompatibility
14
 * @author  Juliette Reinders Folmer <[email protected]>
15
 */
16
class GetFunctionParametersTest extends BaseAbstractClassMethodTest
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
    public $filename = 'sniff-examples/utility-functions/get_function_parameters.php';
20
21
    /**
22
     * testGetFunctionCallParameters
23
     *
24
     * @group utilityFunctions
25
     *
26
     * @dataProvider dataGetFunctionCallParameters
27
     *
28
     * @param int    $stackPtr Stack pointer for a T_CLASS token in the test file.
29
     * @param string $expected The expected fully qualified class name.
30
     */
31
    public function testGetFunctionCallParameters($stackPtr, $expected)
32
    {
33
        $result = $this->helperClass->getFunctionCallParameters($this->_phpcsFile, $stackPtr);
34
        $this->assertSame($expected, $result);
35
    }
36
37
    /**
38
     * dataGetFunctionCallParameters
39
     *
40
     * @see testGetFunctionCallParameters()
41
     *
42
     * @return array
43
     */
44
    public function dataGetFunctionCallParameters()
45
    {
46
        return array(
47
            array(88, array(
48
                       1 => array(
49
                             'start' => 90,
50
                             'end'   => 91,
51
                             'raw'   => '1',
52
                            ),
53
                       2 => array(
54
                             'start' => 93,
55
                             'end'   => 94,
56
                             'raw'   => '2',
57
                            ),
58
                       3 => array(
59
                             'start' => 96,
60
                             'end'   => 97,
61
                             'raw'   => '3',
62
                            ),
63
                       4 => array(
64
                             'start' => 99,
65
                             'end'   => 100,
66
                             'raw'   => '4',
67
                            ),
68
                       5 => array(
69
                             'start' => 102,
70
                             'end'   => 103,
71
                             'raw'   => '5',
72
                            ),
73
                       6 => array(
74
                             'start' => 105,
75
                             'end'   => 106,
76
                             'raw'   => '6',
77
                            ),
78
                       7 => array(
79
                             'start' => 108,
80
                             'end'   => 110,
81
                             'raw'   => 'true',
82
                            ),
83
                      ),
84
85
            ),
86
            array(120, array(
87
                        1 => array(
88
                              'start' => 122,
89
                              'end'   => 129,
90
                              'raw'   => 'dirname( __FILE__ )',
91
                             ),
92
                       ),
93
            ),
94
            array(250, array(
95
                        1 => array(
96
                              'start' => 252,
97
                              'end'   => 252,
98
                              'raw'   => '$stHour',
99
                             ),
100
                        2 => array(
101
                              'start' => 254,
102
                              'end'   => 255,
103
                              'raw'   => '0',
104
                             ),
105
                        3 => array(
106
                              'start' => 257,
107
                              'end'   => 258,
108
                              'raw'   => '0',
109
                             ),
110
                        4 => array(
111
                              'start' => 260,
112
                              'end'   => 264,
113
                              'raw'   => '$arrStDt[0]',
114
                             ),
115
                        5 => array(
116
                              'start' => 266,
117
                              'end'   => 270,
118
                              'raw'   => '$arrStDt[1]',
119
                             ),
120
                        6 => array(
121
                              'start' => 272,
122
                              'end'   => 276,
123
                              'raw'   => '$arrStDt[2]',
124
                             ),
125
                       ),
126
127
            ),
128
        );
129
    }
130
131
132
    /**
133
     * testGetFunctionCallParameter
134
     *
135
     * @group utilityFunctions
136
     *
137
     * @dataProvider dataGetFunctionCallParameter
138
     *
139
     * @param int    $stackPtr Stack pointer for a T_CLASS token in the test file.
140
     * @param string $expected The expected fully qualified class name.
141
     */
142
    public function testGetFunctionCallParameter($stackPtr, $paramPosition, $expected)
143
    {
144
        $result = $this->helperClass->getFunctionCallParameter($this->_phpcsFile, $stackPtr, $paramPosition);
145
        $this->assertSame($expected, $result);
146
    }
147
148
    /**
149
     * dataGetFunctionCallParameter
150
     *
151
     * @see testGetFunctionCallParameter()
152
     *
153
     * @return array
154
     */
155
    public function dataGetFunctionCallParameter()
156
    {
157
        return array(
158
            array(88, 4, array(
159
                          'start' => 99,
160
                          'end'   => 100,
161
                          'raw'   => '4',
162
                         ),
163
            ),
164
            array(120, 1, array(
165
                           'start' => 122,
166
                           'end'   => 129,
167
                           'raw'   => 'dirname( __FILE__ )',
168
                          ),
169
            ),
170
            array(250, 1, array(
171
                           'start' => 252,
172
                           'end'   => 252,
173
                           'raw'   => '$stHour',
174
                          ),
175
            ),
176
            array(250, 6, array(
177
                           'start' => 272,
178
                           'end'   => 276,
179
                           'raw'   => '$arrStDt[2]',
180
                          ),
181
            ),
182
        );
183
    }
184
185
186
    /**
187
     * testGetFunctionCallParameterCount
188
     *
189
     * @group utilityFunctions
190
     *
191
     * @dataProvider dataGetFunctionCallParameterCount
192
     *
193
     * @param int    $stackPtr Stack pointer for a T_CLASS token in the test file.
194
     * @param string $expected The expected fully qualified class name.
195
     */
196
    public function testGetFunctionCallParameterCount($stackPtr, $expected)
197
    {
198
        $result = $this->helperClass->getFunctionCallParameterCount($this->_phpcsFile, $stackPtr);
199
        $this->assertSame($expected, $result);
200
    }
201
202
    /**
203
     * dataGetFunctionCallParameterCount
204
     *
205
     * @see testGetFunctionCallParameterCount()
206
     *
207
     * @return array
208
     */
209
    public function dataGetFunctionCallParameterCount()
210
    {
211
        return array(
212
            array(5, 1),
213
            array(11, 2),
214
            array(22, 3),
215
            array(34, 4),
216
            array(49, 5),
217
            array(67, 6),
218
            array(88, 7),
219
            array(120, 1),
220
            array(135, 1),
221
            array(150, 1),
222
            array(164, 2),
223
            array(181, 1),
224
            array(194, 1),
225
            array(209, 1),
226
            array(228, 2),
227
            array(250, 6),
228
            array(281, 6),
229
            array(312, 6),
230
            array(351, 6),
231
            array(386, 6),
232
            array(420, 6),
233
            array(454, 6),
234
            array(499, 3),
235
            array(518, 1),
236
        );
237
    }
238
239
}
240