@@ -15,22 +15,22 @@ |
||
15 | 15 | */ |
16 | 16 | interface PHPUnit_Framework_MockObject_Builder_Namespace |
17 | 17 | { |
18 | - /** |
|
19 | - * Looks up the match builder with identification $id and returns it. |
|
20 | - * |
|
21 | - * @param string $id The identification of the match builder |
|
22 | - * |
|
23 | - * @return PHPUnit_Framework_MockObject_Builder_Match |
|
24 | - */ |
|
25 | - public function lookupId($id); |
|
18 | + /** |
|
19 | + * Looks up the match builder with identification $id and returns it. |
|
20 | + * |
|
21 | + * @param string $id The identification of the match builder |
|
22 | + * |
|
23 | + * @return PHPUnit_Framework_MockObject_Builder_Match |
|
24 | + */ |
|
25 | + public function lookupId($id); |
|
26 | 26 | |
27 | - /** |
|
28 | - * Registers the match builder $builder with the identification $id. The |
|
29 | - * builder can later be looked up using lookupId() to figure out if it |
|
30 | - * has been invoked. |
|
31 | - * |
|
32 | - * @param string $id The identification of the match builder |
|
33 | - * @param PHPUnit_Framework_MockObject_Builder_Match $builder The builder which is being registered |
|
34 | - */ |
|
35 | - public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder); |
|
27 | + /** |
|
28 | + * Registers the match builder $builder with the identification $id. The |
|
29 | + * builder can later be looked up using lookupId() to figure out if it |
|
30 | + * has been invoked. |
|
31 | + * |
|
32 | + * @param string $id The identification of the match builder |
|
33 | + * @param PHPUnit_Framework_MockObject_Builder_Match $builder The builder which is being registered |
|
34 | + */ |
|
35 | + public function registerId($id, PHPUnit_Framework_MockObject_Builder_Match $builder); |
|
36 | 36 | } |
@@ -18,12 +18,12 @@ |
||
18 | 18 | */ |
19 | 19 | interface PHPUnit_Framework_MockObject_Builder_Identity |
20 | 20 | { |
21 | - /** |
|
22 | - * Sets the identification of the expectation to $id. |
|
23 | - * |
|
24 | - * @note The identifier is unique per mock object. |
|
25 | - * |
|
26 | - * @param string $id Unique identification of expectation. |
|
27 | - */ |
|
28 | - public function id($id); |
|
21 | + /** |
|
22 | + * Sets the identification of the expectation to $id. |
|
23 | + * |
|
24 | + * @note The identifier is unique per mock object. |
|
25 | + * |
|
26 | + * @param string $id Unique identification of expectation. |
|
27 | + */ |
|
28 | + public function id($id); |
|
29 | 29 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | */ |
14 | 14 | interface PHPUnit_Framework_MockObject_Builder_Match extends PHPUnit_Framework_MockObject_Builder_Stub |
15 | 15 | { |
16 | - /** |
|
17 | - * Defines the expectation which must occur before the current is valid. |
|
18 | - * |
|
19 | - * @param string $id The identification of the expectation that should |
|
20 | - * occur before this one. |
|
21 | - * |
|
22 | - * @return PHPUnit_Framework_MockObject_Builder_Stub |
|
23 | - */ |
|
24 | - public function after($id); |
|
16 | + /** |
|
17 | + * Defines the expectation which must occur before the current is valid. |
|
18 | + * |
|
19 | + * @param string $id The identification of the expectation that should |
|
20 | + * occur before this one. |
|
21 | + * |
|
22 | + * @return PHPUnit_Framework_MockObject_Builder_Stub |
|
23 | + */ |
|
24 | + public function after($id); |
|
25 | 25 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | */ |
14 | 14 | interface PHPUnit_Framework_MockObject_Invocation |
15 | 15 | { |
16 | - /** |
|
17 | - * @return mixed Mocked return value. |
|
18 | - */ |
|
19 | - public function generateReturnValue(); |
|
16 | + /** |
|
17 | + * @return mixed Mocked return value. |
|
18 | + */ |
|
19 | + public function generateReturnValue(); |
|
20 | 20 | } |
@@ -18,36 +18,36 @@ |
||
18 | 18 | */ |
19 | 19 | interface PHPUnit_Framework_MockObject_MockObject /*extends PHPUnit_Framework_MockObject_Verifiable*/ |
20 | 20 | { |
21 | - /** |
|
22 | - * Registers a new expectation in the mock object and returns the match |
|
23 | - * object which can be infused with further details. |
|
24 | - * |
|
25 | - * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher |
|
26 | - * |
|
27 | - * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker |
|
28 | - */ |
|
29 | - public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); |
|
21 | + /** |
|
22 | + * Registers a new expectation in the mock object and returns the match |
|
23 | + * object which can be infused with further details. |
|
24 | + * |
|
25 | + * @param PHPUnit_Framework_MockObject_Matcher_Invocation $matcher |
|
26 | + * |
|
27 | + * @return PHPUnit_Framework_MockObject_Builder_InvocationMocker |
|
28 | + */ |
|
29 | + public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher); |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return PHPUnit_Framework_MockObject_InvocationMocker |
|
33 | - */ |
|
34 | - public function __phpunit_setOriginalObject($originalObject); |
|
31 | + /** |
|
32 | + * @return PHPUnit_Framework_MockObject_InvocationMocker |
|
33 | + */ |
|
34 | + public function __phpunit_setOriginalObject($originalObject); |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return PHPUnit_Framework_MockObject_InvocationMocker |
|
38 | - */ |
|
39 | - public function __phpunit_getInvocationMocker(); |
|
36 | + /** |
|
37 | + * @return PHPUnit_Framework_MockObject_InvocationMocker |
|
38 | + */ |
|
39 | + public function __phpunit_getInvocationMocker(); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Verifies that the current expectation is valid. If everything is OK the |
|
43 | - * code should just return, if not it must throw an exception. |
|
44 | - * |
|
45 | - * @throws ExpectationFailedException |
|
46 | - */ |
|
47 | - public function __phpunit_verify(); |
|
41 | + /** |
|
42 | + * Verifies that the current expectation is valid. If everything is OK the |
|
43 | + * code should just return, if not it must throw an exception. |
|
44 | + * |
|
45 | + * @throws ExpectationFailedException |
|
46 | + */ |
|
47 | + public function __phpunit_verify(); |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - public function __phpunit_hasMatchers(); |
|
49 | + /** |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + public function __phpunit_hasMatchers(); |
|
53 | 53 | } |
@@ -19,325 +19,325 @@ |
||
19 | 19 | */ |
20 | 20 | abstract class TestCase extends \PHPUnit\Framework\TestCase |
21 | 21 | { |
22 | - protected static $TEST_TMP_PATH; |
|
23 | - |
|
24 | - public static function setUpBeforeClass() |
|
25 | - { |
|
26 | - self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp'; |
|
27 | - } |
|
28 | - |
|
29 | - protected function getXdebugDataForBankAccount() |
|
30 | - { |
|
31 | - return [ |
|
32 | - [ |
|
33 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
34 | - 8 => 1, |
|
35 | - 9 => -2, |
|
36 | - 13 => -1, |
|
37 | - 14 => -1, |
|
38 | - 15 => -1, |
|
39 | - 16 => -1, |
|
40 | - 18 => -1, |
|
41 | - 22 => -1, |
|
42 | - 24 => -1, |
|
43 | - 25 => -2, |
|
44 | - 29 => -1, |
|
45 | - 31 => -1, |
|
46 | - 32 => -2 |
|
47 | - ] |
|
48 | - ], |
|
49 | - [ |
|
50 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
51 | - 8 => 1, |
|
52 | - 13 => 1, |
|
53 | - 16 => 1, |
|
54 | - 29 => 1, |
|
55 | - ] |
|
56 | - ], |
|
57 | - [ |
|
58 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
59 | - 8 => 1, |
|
60 | - 13 => 1, |
|
61 | - 16 => 1, |
|
62 | - 22 => 1, |
|
63 | - ] |
|
64 | - ], |
|
65 | - [ |
|
66 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
67 | - 8 => 1, |
|
68 | - 13 => 1, |
|
69 | - 14 => 1, |
|
70 | - 15 => 1, |
|
71 | - 18 => 1, |
|
72 | - 22 => 1, |
|
73 | - 24 => 1, |
|
74 | - 29 => 1, |
|
75 | - 31 => 1, |
|
76 | - ] |
|
77 | - ] |
|
78 | - ]; |
|
79 | - } |
|
80 | - |
|
81 | - protected function getCoverageForBankAccount() |
|
82 | - { |
|
83 | - $data = $this->getXdebugDataForBankAccount(); |
|
84 | - require_once TEST_FILES_PATH . '/BankAccountTest.php'; |
|
85 | - |
|
86 | - $stub = $this->createMock(Xdebug::class); |
|
87 | - |
|
88 | - $stub->expects($this->any()) |
|
89 | - ->method('stop') |
|
90 | - ->will($this->onConsecutiveCalls( |
|
91 | - $data[0], |
|
92 | - $data[1], |
|
93 | - $data[2], |
|
94 | - $data[3] |
|
95 | - )); |
|
96 | - |
|
97 | - $filter = new Filter; |
|
98 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
99 | - |
|
100 | - $coverage = new CodeCoverage($stub, $filter); |
|
101 | - |
|
102 | - $coverage->start( |
|
103 | - new \BankAccountTest('testBalanceIsInitiallyZero'), |
|
104 | - true |
|
105 | - ); |
|
106 | - |
|
107 | - $coverage->stop( |
|
108 | - true, |
|
109 | - [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
110 | - ); |
|
111 | - |
|
112 | - $coverage->start( |
|
113 | - new \BankAccountTest('testBalanceCannotBecomeNegative') |
|
114 | - ); |
|
115 | - |
|
116 | - $coverage->stop( |
|
117 | - true, |
|
118 | - [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
119 | - ); |
|
120 | - |
|
121 | - $coverage->start( |
|
122 | - new \BankAccountTest('testBalanceCannotBecomeNegative2') |
|
123 | - ); |
|
124 | - |
|
125 | - $coverage->stop( |
|
126 | - true, |
|
127 | - [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
128 | - ); |
|
129 | - |
|
130 | - $coverage->start( |
|
131 | - new \BankAccountTest('testDepositWithdrawMoney') |
|
132 | - ); |
|
133 | - |
|
134 | - $coverage->stop( |
|
135 | - true, |
|
136 | - [ |
|
137 | - TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
138 | - range(6, 9), |
|
139 | - range(20, 25), |
|
140 | - range(27, 32) |
|
141 | - ) |
|
142 | - ] |
|
143 | - ); |
|
144 | - |
|
145 | - return $coverage; |
|
146 | - } |
|
147 | - |
|
148 | - protected function getCoverageForBankAccountForFirstTwoTests() |
|
149 | - { |
|
150 | - $data = $this->getXdebugDataForBankAccount(); |
|
151 | - |
|
152 | - $stub = $this->createMock(Xdebug::class); |
|
153 | - |
|
154 | - $stub->expects($this->any()) |
|
155 | - ->method('stop') |
|
156 | - ->will($this->onConsecutiveCalls( |
|
157 | - $data[0], |
|
158 | - $data[1] |
|
159 | - )); |
|
160 | - |
|
161 | - $filter = new Filter; |
|
162 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
163 | - |
|
164 | - $coverage = new CodeCoverage($stub, $filter); |
|
165 | - |
|
166 | - $coverage->start( |
|
167 | - new \BankAccountTest('testBalanceIsInitiallyZero'), |
|
168 | - true |
|
169 | - ); |
|
170 | - |
|
171 | - $coverage->stop( |
|
172 | - true, |
|
173 | - [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
174 | - ); |
|
175 | - |
|
176 | - $coverage->start( |
|
177 | - new \BankAccountTest('testBalanceCannotBecomeNegative') |
|
178 | - ); |
|
179 | - |
|
180 | - $coverage->stop( |
|
181 | - true, |
|
182 | - [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
183 | - ); |
|
184 | - |
|
185 | - return $coverage; |
|
186 | - } |
|
187 | - |
|
188 | - protected function getCoverageForBankAccountForLastTwoTests() |
|
189 | - { |
|
190 | - $data = $this->getXdebugDataForBankAccount(); |
|
191 | - |
|
192 | - $stub = $this->createMock(Xdebug::class); |
|
193 | - |
|
194 | - $stub->expects($this->any()) |
|
195 | - ->method('stop') |
|
196 | - ->will($this->onConsecutiveCalls( |
|
197 | - $data[2], |
|
198 | - $data[3] |
|
199 | - )); |
|
200 | - |
|
201 | - $filter = new Filter; |
|
202 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
203 | - |
|
204 | - $coverage = new CodeCoverage($stub, $filter); |
|
205 | - |
|
206 | - $coverage->start( |
|
207 | - new \BankAccountTest('testBalanceCannotBecomeNegative2') |
|
208 | - ); |
|
209 | - |
|
210 | - $coverage->stop( |
|
211 | - true, |
|
212 | - [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
213 | - ); |
|
214 | - |
|
215 | - $coverage->start( |
|
216 | - new \BankAccountTest('testDepositWithdrawMoney') |
|
217 | - ); |
|
218 | - |
|
219 | - $coverage->stop( |
|
220 | - true, |
|
221 | - [ |
|
222 | - TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
223 | - range(6, 9), |
|
224 | - range(20, 25), |
|
225 | - range(27, 32) |
|
226 | - ) |
|
227 | - ] |
|
228 | - ); |
|
229 | - |
|
230 | - return $coverage; |
|
231 | - } |
|
232 | - |
|
233 | - protected function getExpectedDataArrayForBankAccount() |
|
234 | - { |
|
235 | - return [ |
|
236 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
237 | - 8 => [ |
|
238 | - 0 => 'BankAccountTest::testBalanceIsInitiallyZero', |
|
239 | - 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
240 | - ], |
|
241 | - 9 => null, |
|
242 | - 13 => [], |
|
243 | - 14 => [], |
|
244 | - 15 => [], |
|
245 | - 16 => [], |
|
246 | - 18 => [], |
|
247 | - 22 => [ |
|
248 | - 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', |
|
249 | - 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
250 | - ], |
|
251 | - 24 => [ |
|
252 | - 0 => 'BankAccountTest::testDepositWithdrawMoney', |
|
253 | - ], |
|
254 | - 25 => null, |
|
255 | - 29 => [ |
|
256 | - 0 => 'BankAccountTest::testBalanceCannotBecomeNegative', |
|
257 | - 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
258 | - ], |
|
259 | - 31 => [ |
|
260 | - 0 => 'BankAccountTest::testDepositWithdrawMoney' |
|
261 | - ], |
|
262 | - 32 => null |
|
263 | - ] |
|
264 | - ]; |
|
265 | - } |
|
266 | - |
|
267 | - protected function getCoverageForFileWithIgnoredLines() |
|
268 | - { |
|
269 | - $filter = new Filter; |
|
270 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_ignore.php'); |
|
271 | - |
|
272 | - $coverage = new CodeCoverage( |
|
273 | - $this->setUpXdebugStubForFileWithIgnoredLines(), |
|
274 | - $filter |
|
275 | - ); |
|
276 | - |
|
277 | - $coverage->start('FileWithIgnoredLines', true); |
|
278 | - $coverage->stop(); |
|
279 | - |
|
280 | - return $coverage; |
|
281 | - } |
|
282 | - |
|
283 | - protected function setUpXdebugStubForFileWithIgnoredLines() |
|
284 | - { |
|
285 | - $stub = $this->createMock(Xdebug::class); |
|
286 | - |
|
287 | - $stub->expects($this->any()) |
|
288 | - ->method('stop') |
|
289 | - ->will($this->returnValue( |
|
290 | - [ |
|
291 | - TEST_FILES_PATH . 'source_with_ignore.php' => [ |
|
292 | - 2 => 1, |
|
293 | - 4 => -1, |
|
294 | - 6 => -1, |
|
295 | - 7 => 1 |
|
296 | - ] |
|
297 | - ] |
|
298 | - )); |
|
299 | - |
|
300 | - return $stub; |
|
301 | - } |
|
302 | - |
|
303 | - protected function getCoverageForClassWithAnonymousFunction() |
|
304 | - { |
|
305 | - $filter = new Filter; |
|
306 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'); |
|
307 | - |
|
308 | - $coverage = new CodeCoverage( |
|
309 | - $this->setUpXdebugStubForClassWithAnonymousFunction(), |
|
310 | - $filter |
|
311 | - ); |
|
312 | - |
|
313 | - $coverage->start('ClassWithAnonymousFunction', true); |
|
314 | - $coverage->stop(); |
|
315 | - |
|
316 | - return $coverage; |
|
317 | - } |
|
318 | - |
|
319 | - protected function setUpXdebugStubForClassWithAnonymousFunction() |
|
320 | - { |
|
321 | - $stub = $this->createMock(Xdebug::class); |
|
322 | - |
|
323 | - $stub->expects($this->any()) |
|
324 | - ->method('stop') |
|
325 | - ->will($this->returnValue( |
|
326 | - [ |
|
327 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' => [ |
|
328 | - 7 => 1, |
|
329 | - 9 => 1, |
|
330 | - 10 => -1, |
|
331 | - 11 => 1, |
|
332 | - 12 => 1, |
|
333 | - 13 => 1, |
|
334 | - 14 => 1, |
|
335 | - 17 => 1, |
|
336 | - 18 => 1 |
|
337 | - ] |
|
338 | - ] |
|
339 | - )); |
|
340 | - |
|
341 | - return $stub; |
|
342 | - } |
|
22 | + protected static $TEST_TMP_PATH; |
|
23 | + |
|
24 | + public static function setUpBeforeClass() |
|
25 | + { |
|
26 | + self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp'; |
|
27 | + } |
|
28 | + |
|
29 | + protected function getXdebugDataForBankAccount() |
|
30 | + { |
|
31 | + return [ |
|
32 | + [ |
|
33 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
34 | + 8 => 1, |
|
35 | + 9 => -2, |
|
36 | + 13 => -1, |
|
37 | + 14 => -1, |
|
38 | + 15 => -1, |
|
39 | + 16 => -1, |
|
40 | + 18 => -1, |
|
41 | + 22 => -1, |
|
42 | + 24 => -1, |
|
43 | + 25 => -2, |
|
44 | + 29 => -1, |
|
45 | + 31 => -1, |
|
46 | + 32 => -2 |
|
47 | + ] |
|
48 | + ], |
|
49 | + [ |
|
50 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
51 | + 8 => 1, |
|
52 | + 13 => 1, |
|
53 | + 16 => 1, |
|
54 | + 29 => 1, |
|
55 | + ] |
|
56 | + ], |
|
57 | + [ |
|
58 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
59 | + 8 => 1, |
|
60 | + 13 => 1, |
|
61 | + 16 => 1, |
|
62 | + 22 => 1, |
|
63 | + ] |
|
64 | + ], |
|
65 | + [ |
|
66 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
67 | + 8 => 1, |
|
68 | + 13 => 1, |
|
69 | + 14 => 1, |
|
70 | + 15 => 1, |
|
71 | + 18 => 1, |
|
72 | + 22 => 1, |
|
73 | + 24 => 1, |
|
74 | + 29 => 1, |
|
75 | + 31 => 1, |
|
76 | + ] |
|
77 | + ] |
|
78 | + ]; |
|
79 | + } |
|
80 | + |
|
81 | + protected function getCoverageForBankAccount() |
|
82 | + { |
|
83 | + $data = $this->getXdebugDataForBankAccount(); |
|
84 | + require_once TEST_FILES_PATH . '/BankAccountTest.php'; |
|
85 | + |
|
86 | + $stub = $this->createMock(Xdebug::class); |
|
87 | + |
|
88 | + $stub->expects($this->any()) |
|
89 | + ->method('stop') |
|
90 | + ->will($this->onConsecutiveCalls( |
|
91 | + $data[0], |
|
92 | + $data[1], |
|
93 | + $data[2], |
|
94 | + $data[3] |
|
95 | + )); |
|
96 | + |
|
97 | + $filter = new Filter; |
|
98 | + $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
99 | + |
|
100 | + $coverage = new CodeCoverage($stub, $filter); |
|
101 | + |
|
102 | + $coverage->start( |
|
103 | + new \BankAccountTest('testBalanceIsInitiallyZero'), |
|
104 | + true |
|
105 | + ); |
|
106 | + |
|
107 | + $coverage->stop( |
|
108 | + true, |
|
109 | + [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
110 | + ); |
|
111 | + |
|
112 | + $coverage->start( |
|
113 | + new \BankAccountTest('testBalanceCannotBecomeNegative') |
|
114 | + ); |
|
115 | + |
|
116 | + $coverage->stop( |
|
117 | + true, |
|
118 | + [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
119 | + ); |
|
120 | + |
|
121 | + $coverage->start( |
|
122 | + new \BankAccountTest('testBalanceCannotBecomeNegative2') |
|
123 | + ); |
|
124 | + |
|
125 | + $coverage->stop( |
|
126 | + true, |
|
127 | + [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
128 | + ); |
|
129 | + |
|
130 | + $coverage->start( |
|
131 | + new \BankAccountTest('testDepositWithdrawMoney') |
|
132 | + ); |
|
133 | + |
|
134 | + $coverage->stop( |
|
135 | + true, |
|
136 | + [ |
|
137 | + TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
138 | + range(6, 9), |
|
139 | + range(20, 25), |
|
140 | + range(27, 32) |
|
141 | + ) |
|
142 | + ] |
|
143 | + ); |
|
144 | + |
|
145 | + return $coverage; |
|
146 | + } |
|
147 | + |
|
148 | + protected function getCoverageForBankAccountForFirstTwoTests() |
|
149 | + { |
|
150 | + $data = $this->getXdebugDataForBankAccount(); |
|
151 | + |
|
152 | + $stub = $this->createMock(Xdebug::class); |
|
153 | + |
|
154 | + $stub->expects($this->any()) |
|
155 | + ->method('stop') |
|
156 | + ->will($this->onConsecutiveCalls( |
|
157 | + $data[0], |
|
158 | + $data[1] |
|
159 | + )); |
|
160 | + |
|
161 | + $filter = new Filter; |
|
162 | + $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
163 | + |
|
164 | + $coverage = new CodeCoverage($stub, $filter); |
|
165 | + |
|
166 | + $coverage->start( |
|
167 | + new \BankAccountTest('testBalanceIsInitiallyZero'), |
|
168 | + true |
|
169 | + ); |
|
170 | + |
|
171 | + $coverage->stop( |
|
172 | + true, |
|
173 | + [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
174 | + ); |
|
175 | + |
|
176 | + $coverage->start( |
|
177 | + new \BankAccountTest('testBalanceCannotBecomeNegative') |
|
178 | + ); |
|
179 | + |
|
180 | + $coverage->stop( |
|
181 | + true, |
|
182 | + [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
183 | + ); |
|
184 | + |
|
185 | + return $coverage; |
|
186 | + } |
|
187 | + |
|
188 | + protected function getCoverageForBankAccountForLastTwoTests() |
|
189 | + { |
|
190 | + $data = $this->getXdebugDataForBankAccount(); |
|
191 | + |
|
192 | + $stub = $this->createMock(Xdebug::class); |
|
193 | + |
|
194 | + $stub->expects($this->any()) |
|
195 | + ->method('stop') |
|
196 | + ->will($this->onConsecutiveCalls( |
|
197 | + $data[2], |
|
198 | + $data[3] |
|
199 | + )); |
|
200 | + |
|
201 | + $filter = new Filter; |
|
202 | + $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
203 | + |
|
204 | + $coverage = new CodeCoverage($stub, $filter); |
|
205 | + |
|
206 | + $coverage->start( |
|
207 | + new \BankAccountTest('testBalanceCannotBecomeNegative2') |
|
208 | + ); |
|
209 | + |
|
210 | + $coverage->stop( |
|
211 | + true, |
|
212 | + [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
213 | + ); |
|
214 | + |
|
215 | + $coverage->start( |
|
216 | + new \BankAccountTest('testDepositWithdrawMoney') |
|
217 | + ); |
|
218 | + |
|
219 | + $coverage->stop( |
|
220 | + true, |
|
221 | + [ |
|
222 | + TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
223 | + range(6, 9), |
|
224 | + range(20, 25), |
|
225 | + range(27, 32) |
|
226 | + ) |
|
227 | + ] |
|
228 | + ); |
|
229 | + |
|
230 | + return $coverage; |
|
231 | + } |
|
232 | + |
|
233 | + protected function getExpectedDataArrayForBankAccount() |
|
234 | + { |
|
235 | + return [ |
|
236 | + TEST_FILES_PATH . 'BankAccount.php' => [ |
|
237 | + 8 => [ |
|
238 | + 0 => 'BankAccountTest::testBalanceIsInitiallyZero', |
|
239 | + 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
240 | + ], |
|
241 | + 9 => null, |
|
242 | + 13 => [], |
|
243 | + 14 => [], |
|
244 | + 15 => [], |
|
245 | + 16 => [], |
|
246 | + 18 => [], |
|
247 | + 22 => [ |
|
248 | + 0 => 'BankAccountTest::testBalanceCannotBecomeNegative2', |
|
249 | + 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
250 | + ], |
|
251 | + 24 => [ |
|
252 | + 0 => 'BankAccountTest::testDepositWithdrawMoney', |
|
253 | + ], |
|
254 | + 25 => null, |
|
255 | + 29 => [ |
|
256 | + 0 => 'BankAccountTest::testBalanceCannotBecomeNegative', |
|
257 | + 1 => 'BankAccountTest::testDepositWithdrawMoney' |
|
258 | + ], |
|
259 | + 31 => [ |
|
260 | + 0 => 'BankAccountTest::testDepositWithdrawMoney' |
|
261 | + ], |
|
262 | + 32 => null |
|
263 | + ] |
|
264 | + ]; |
|
265 | + } |
|
266 | + |
|
267 | + protected function getCoverageForFileWithIgnoredLines() |
|
268 | + { |
|
269 | + $filter = new Filter; |
|
270 | + $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_ignore.php'); |
|
271 | + |
|
272 | + $coverage = new CodeCoverage( |
|
273 | + $this->setUpXdebugStubForFileWithIgnoredLines(), |
|
274 | + $filter |
|
275 | + ); |
|
276 | + |
|
277 | + $coverage->start('FileWithIgnoredLines', true); |
|
278 | + $coverage->stop(); |
|
279 | + |
|
280 | + return $coverage; |
|
281 | + } |
|
282 | + |
|
283 | + protected function setUpXdebugStubForFileWithIgnoredLines() |
|
284 | + { |
|
285 | + $stub = $this->createMock(Xdebug::class); |
|
286 | + |
|
287 | + $stub->expects($this->any()) |
|
288 | + ->method('stop') |
|
289 | + ->will($this->returnValue( |
|
290 | + [ |
|
291 | + TEST_FILES_PATH . 'source_with_ignore.php' => [ |
|
292 | + 2 => 1, |
|
293 | + 4 => -1, |
|
294 | + 6 => -1, |
|
295 | + 7 => 1 |
|
296 | + ] |
|
297 | + ] |
|
298 | + )); |
|
299 | + |
|
300 | + return $stub; |
|
301 | + } |
|
302 | + |
|
303 | + protected function getCoverageForClassWithAnonymousFunction() |
|
304 | + { |
|
305 | + $filter = new Filter; |
|
306 | + $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'); |
|
307 | + |
|
308 | + $coverage = new CodeCoverage( |
|
309 | + $this->setUpXdebugStubForClassWithAnonymousFunction(), |
|
310 | + $filter |
|
311 | + ); |
|
312 | + |
|
313 | + $coverage->start('ClassWithAnonymousFunction', true); |
|
314 | + $coverage->stop(); |
|
315 | + |
|
316 | + return $coverage; |
|
317 | + } |
|
318 | + |
|
319 | + protected function setUpXdebugStubForClassWithAnonymousFunction() |
|
320 | + { |
|
321 | + $stub = $this->createMock(Xdebug::class); |
|
322 | + |
|
323 | + $stub->expects($this->any()) |
|
324 | + ->method('stop') |
|
325 | + ->will($this->returnValue( |
|
326 | + [ |
|
327 | + TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' => [ |
|
328 | + 7 => 1, |
|
329 | + 9 => 1, |
|
330 | + 10 => -1, |
|
331 | + 11 => 1, |
|
332 | + 12 => 1, |
|
333 | + 13 => 1, |
|
334 | + 14 => 1, |
|
335 | + 17 => 1, |
|
336 | + 18 => 1 |
|
337 | + ] |
|
338 | + ] |
|
339 | + )); |
|
340 | + |
|
341 | + return $stub; |
|
342 | + } |
|
343 | 343 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function setUpBeforeClass() |
25 | 25 | { |
26 | - self::$TEST_TMP_PATH = TEST_FILES_PATH . 'tmp'; |
|
26 | + self::$TEST_TMP_PATH = TEST_FILES_PATH.'tmp'; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function getXdebugDataForBankAccount() |
30 | 30 | { |
31 | 31 | return [ |
32 | 32 | [ |
33 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
33 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
34 | 34 | 8 => 1, |
35 | 35 | 9 => -2, |
36 | 36 | 13 => -1, |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ] |
48 | 48 | ], |
49 | 49 | [ |
50 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
50 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
51 | 51 | 8 => 1, |
52 | 52 | 13 => 1, |
53 | 53 | 16 => 1, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ] |
56 | 56 | ], |
57 | 57 | [ |
58 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
58 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
59 | 59 | 8 => 1, |
60 | 60 | 13 => 1, |
61 | 61 | 16 => 1, |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ] |
64 | 64 | ], |
65 | 65 | [ |
66 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
66 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
67 | 67 | 8 => 1, |
68 | 68 | 13 => 1, |
69 | 69 | 14 => 1, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | protected function getCoverageForBankAccount() |
82 | 82 | { |
83 | 83 | $data = $this->getXdebugDataForBankAccount(); |
84 | - require_once TEST_FILES_PATH . '/BankAccountTest.php'; |
|
84 | + require_once TEST_FILES_PATH.'/BankAccountTest.php'; |
|
85 | 85 | |
86 | 86 | $stub = $this->createMock(Xdebug::class); |
87 | 87 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | )); |
96 | 96 | |
97 | 97 | $filter = new Filter; |
98 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
98 | + $filter->addFileToWhitelist(TEST_FILES_PATH.'BankAccount.php'); |
|
99 | 99 | |
100 | 100 | $coverage = new CodeCoverage($stub, $filter); |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $coverage->stop( |
108 | 108 | true, |
109 | - [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
109 | + [TEST_FILES_PATH.'BankAccount.php' => range(6, 9)] |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $coverage->start( |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $coverage->stop( |
117 | 117 | true, |
118 | - [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
118 | + [TEST_FILES_PATH.'BankAccount.php' => range(27, 32)] |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | $coverage->start( |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $coverage->stop( |
126 | 126 | true, |
127 | - [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
127 | + [TEST_FILES_PATH.'BankAccount.php' => range(20, 25)] |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | $coverage->start( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $coverage->stop( |
135 | 135 | true, |
136 | 136 | [ |
137 | - TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
137 | + TEST_FILES_PATH.'BankAccount.php' => array_merge( |
|
138 | 138 | range(6, 9), |
139 | 139 | range(20, 25), |
140 | 140 | range(27, 32) |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | )); |
160 | 160 | |
161 | 161 | $filter = new Filter; |
162 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
162 | + $filter->addFileToWhitelist(TEST_FILES_PATH.'BankAccount.php'); |
|
163 | 163 | |
164 | 164 | $coverage = new CodeCoverage($stub, $filter); |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | $coverage->stop( |
172 | 172 | true, |
173 | - [TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)] |
|
173 | + [TEST_FILES_PATH.'BankAccount.php' => range(6, 9)] |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | $coverage->start( |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $coverage->stop( |
181 | 181 | true, |
182 | - [TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)] |
|
182 | + [TEST_FILES_PATH.'BankAccount.php' => range(27, 32)] |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | return $coverage; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | )); |
200 | 200 | |
201 | 201 | $filter = new Filter; |
202 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'BankAccount.php'); |
|
202 | + $filter->addFileToWhitelist(TEST_FILES_PATH.'BankAccount.php'); |
|
203 | 203 | |
204 | 204 | $coverage = new CodeCoverage($stub, $filter); |
205 | 205 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $coverage->stop( |
211 | 211 | true, |
212 | - [TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)] |
|
212 | + [TEST_FILES_PATH.'BankAccount.php' => range(20, 25)] |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | $coverage->start( |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $coverage->stop( |
220 | 220 | true, |
221 | 221 | [ |
222 | - TEST_FILES_PATH . 'BankAccount.php' => array_merge( |
|
222 | + TEST_FILES_PATH.'BankAccount.php' => array_merge( |
|
223 | 223 | range(6, 9), |
224 | 224 | range(20, 25), |
225 | 225 | range(27, 32) |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | protected function getExpectedDataArrayForBankAccount() |
234 | 234 | { |
235 | 235 | return [ |
236 | - TEST_FILES_PATH . 'BankAccount.php' => [ |
|
236 | + TEST_FILES_PATH.'BankAccount.php' => [ |
|
237 | 237 | 8 => [ |
238 | 238 | 0 => 'BankAccountTest::testBalanceIsInitiallyZero', |
239 | 239 | 1 => 'BankAccountTest::testDepositWithdrawMoney' |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | protected function getCoverageForFileWithIgnoredLines() |
268 | 268 | { |
269 | 269 | $filter = new Filter; |
270 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_ignore.php'); |
|
270 | + $filter->addFileToWhitelist(TEST_FILES_PATH.'source_with_ignore.php'); |
|
271 | 271 | |
272 | 272 | $coverage = new CodeCoverage( |
273 | 273 | $this->setUpXdebugStubForFileWithIgnoredLines(), |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | ->method('stop') |
289 | 289 | ->will($this->returnValue( |
290 | 290 | [ |
291 | - TEST_FILES_PATH . 'source_with_ignore.php' => [ |
|
291 | + TEST_FILES_PATH.'source_with_ignore.php' => [ |
|
292 | 292 | 2 => 1, |
293 | 293 | 4 => -1, |
294 | 294 | 6 => -1, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | protected function getCoverageForClassWithAnonymousFunction() |
304 | 304 | { |
305 | 305 | $filter = new Filter; |
306 | - $filter->addFileToWhitelist(TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php'); |
|
306 | + $filter->addFileToWhitelist(TEST_FILES_PATH.'source_with_class_and_anonymous_function.php'); |
|
307 | 307 | |
308 | 308 | $coverage = new CodeCoverage( |
309 | 309 | $this->setUpXdebugStubForClassWithAnonymousFunction(), |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | ->method('stop') |
325 | 325 | ->will($this->returnValue( |
326 | 326 | [ |
327 | - TEST_FILES_PATH . 'source_with_class_and_anonymous_function.php' => [ |
|
327 | + TEST_FILES_PATH.'source_with_class_and_anonymous_function.php' => [ |
|
328 | 328 | 7 => 1, |
329 | 329 | 9 => 1, |
330 | 330 | 10 => -1, |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require __DIR__ . '/../vendor/autoload.php'; |
|
3 | -require __DIR__ . '/TestCase.php'; |
|
2 | +require __DIR__.'/../vendor/autoload.php'; |
|
3 | +require __DIR__.'/TestCase.php'; |
|
4 | 4 | |
5 | -define('TEST_FILES_PATH', __DIR__ . '/_files/'); |
|
5 | +define('TEST_FILES_PATH', __DIR__.'/_files/'); |
@@ -17,13 +17,13 @@ |
||
17 | 17 | */ |
18 | 18 | class UtilTest extends TestCase |
19 | 19 | { |
20 | - public function testPercent() |
|
21 | - { |
|
22 | - $this->assertEquals(100, Util::percent(100, 0)); |
|
23 | - $this->assertEquals(100, Util::percent(100, 100)); |
|
24 | - $this->assertEquals( |
|
25 | - '100.00%', |
|
26 | - Util::percent(100, 100, true) |
|
27 | - ); |
|
28 | - } |
|
20 | + public function testPercent() |
|
21 | + { |
|
22 | + $this->assertEquals(100, Util::percent(100, 0)); |
|
23 | + $this->assertEquals(100, Util::percent(100, 100)); |
|
24 | + $this->assertEquals( |
|
25 | + '100.00%', |
|
26 | + Util::percent(100, 100, true) |
|
27 | + ); |
|
28 | + } |
|
29 | 29 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | */ |
18 | 18 | class TextTest extends TestCase |
19 | 19 | { |
20 | - public function testTextForBankAccountTest() |
|
21 | - { |
|
22 | - $text = new Text(50, 90, false, false); |
|
23 | - |
|
24 | - $this->assertStringMatchesFormatFile( |
|
25 | - TEST_FILES_PATH . 'BankAccount-text.txt', |
|
26 | - str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount())) |
|
27 | - ); |
|
28 | - } |
|
29 | - |
|
30 | - public function testTextForFileWithIgnoredLines() |
|
31 | - { |
|
32 | - $text = new Text(50, 90, false, false); |
|
33 | - |
|
34 | - $this->assertStringMatchesFormatFile( |
|
35 | - TEST_FILES_PATH . 'ignored-lines-text.txt', |
|
36 | - str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines())) |
|
37 | - ); |
|
38 | - } |
|
39 | - |
|
40 | - public function testTextForClassWithAnonymousFunction() |
|
41 | - { |
|
42 | - $text = new Text(50, 90, false, false); |
|
43 | - |
|
44 | - $this->assertStringMatchesFormatFile( |
|
45 | - TEST_FILES_PATH . 'class-with-anonymous-function-text.txt', |
|
46 | - str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction())) |
|
47 | - ); |
|
48 | - } |
|
20 | + public function testTextForBankAccountTest() |
|
21 | + { |
|
22 | + $text = new Text(50, 90, false, false); |
|
23 | + |
|
24 | + $this->assertStringMatchesFormatFile( |
|
25 | + TEST_FILES_PATH . 'BankAccount-text.txt', |
|
26 | + str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount())) |
|
27 | + ); |
|
28 | + } |
|
29 | + |
|
30 | + public function testTextForFileWithIgnoredLines() |
|
31 | + { |
|
32 | + $text = new Text(50, 90, false, false); |
|
33 | + |
|
34 | + $this->assertStringMatchesFormatFile( |
|
35 | + TEST_FILES_PATH . 'ignored-lines-text.txt', |
|
36 | + str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines())) |
|
37 | + ); |
|
38 | + } |
|
39 | + |
|
40 | + public function testTextForClassWithAnonymousFunction() |
|
41 | + { |
|
42 | + $text = new Text(50, 90, false, false); |
|
43 | + |
|
44 | + $this->assertStringMatchesFormatFile( |
|
45 | + TEST_FILES_PATH . 'class-with-anonymous-function-text.txt', |
|
46 | + str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction())) |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $text = new Text(50, 90, false, false); |
23 | 23 | |
24 | 24 | $this->assertStringMatchesFormatFile( |
25 | - TEST_FILES_PATH . 'BankAccount-text.txt', |
|
25 | + TEST_FILES_PATH.'BankAccount-text.txt', |
|
26 | 26 | str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForBankAccount())) |
27 | 27 | ); |
28 | 28 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $text = new Text(50, 90, false, false); |
33 | 33 | |
34 | 34 | $this->assertStringMatchesFormatFile( |
35 | - TEST_FILES_PATH . 'ignored-lines-text.txt', |
|
35 | + TEST_FILES_PATH.'ignored-lines-text.txt', |
|
36 | 36 | str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForFileWithIgnoredLines())) |
37 | 37 | ); |
38 | 38 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $text = new Text(50, 90, false, false); |
43 | 43 | |
44 | 44 | $this->assertStringMatchesFormatFile( |
45 | - TEST_FILES_PATH . 'class-with-anonymous-function-text.txt', |
|
45 | + TEST_FILES_PATH.'class-with-anonymous-function-text.txt', |
|
46 | 46 | str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction())) |
47 | 47 | ); |
48 | 48 | } |