@@ -25,985 +25,985 @@ |
||
25 | 25 | */ |
26 | 26 | class TestSuite implements Test, SelfDescribing, IteratorAggregate |
27 | 27 | { |
28 | - /** |
|
29 | - * Last count of tests in this suite. |
|
30 | - * |
|
31 | - * @var int|null |
|
32 | - */ |
|
33 | - private $cachedNumTests; |
|
34 | - |
|
35 | - /** |
|
36 | - * Enable or disable the backup and restoration of the $GLOBALS array. |
|
37 | - * |
|
38 | - * @var bool |
|
39 | - */ |
|
40 | - protected $backupGlobals; |
|
41 | - |
|
42 | - /** |
|
43 | - * Enable or disable the backup and restoration of static attributes. |
|
44 | - * |
|
45 | - * @var bool |
|
46 | - */ |
|
47 | - protected $backupStaticAttributes; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var bool |
|
51 | - */ |
|
52 | - private $beStrictAboutChangesToGlobalState; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var bool |
|
56 | - */ |
|
57 | - protected $runTestInSeparateProcess = false; |
|
58 | - |
|
59 | - /** |
|
60 | - * The name of the test suite. |
|
61 | - * |
|
62 | - * @var string |
|
63 | - */ |
|
64 | - protected $name = ''; |
|
65 | - |
|
66 | - /** |
|
67 | - * The test groups of the test suite. |
|
68 | - * |
|
69 | - * @var array |
|
70 | - */ |
|
71 | - protected $groups = []; |
|
72 | - |
|
73 | - /** |
|
74 | - * The tests in the test suite. |
|
75 | - * |
|
76 | - * @var TestCase[] |
|
77 | - */ |
|
78 | - protected $tests = []; |
|
79 | - |
|
80 | - /** |
|
81 | - * The number of tests in the test suite. |
|
82 | - * |
|
83 | - * @var int |
|
84 | - */ |
|
85 | - protected $numTests = -1; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var bool |
|
89 | - */ |
|
90 | - protected $testCase = false; |
|
91 | - |
|
92 | - /** |
|
93 | - * @var array |
|
94 | - */ |
|
95 | - protected $foundClasses = []; |
|
96 | - |
|
97 | - /** |
|
98 | - * @var Factory |
|
99 | - */ |
|
100 | - private $iteratorFilter; |
|
101 | - |
|
102 | - /** |
|
103 | - * Constructs a new TestSuite: |
|
104 | - * |
|
105 | - * - PHPUnit\Framework\TestSuite() constructs an empty TestSuite. |
|
106 | - * |
|
107 | - * - PHPUnit\Framework\TestSuite(ReflectionClass) constructs a |
|
108 | - * TestSuite from the given class. |
|
109 | - * |
|
110 | - * - PHPUnit\Framework\TestSuite(ReflectionClass, String) |
|
111 | - * constructs a TestSuite from the given class with the given |
|
112 | - * name. |
|
113 | - * |
|
114 | - * - PHPUnit\Framework\TestSuite(String) either constructs a |
|
115 | - * TestSuite from the given class (if the passed string is the |
|
116 | - * name of an existing class) or constructs an empty TestSuite |
|
117 | - * with the given name. |
|
118 | - * |
|
119 | - * @param mixed $theClass |
|
120 | - * @param string $name |
|
121 | - * |
|
122 | - * @throws Exception |
|
123 | - */ |
|
124 | - public function __construct($theClass = '', $name = '') |
|
125 | - { |
|
126 | - $argumentsValid = false; |
|
127 | - |
|
128 | - if (\is_object($theClass) && |
|
129 | - $theClass instanceof ReflectionClass) { |
|
130 | - $argumentsValid = true; |
|
131 | - } elseif (\is_string($theClass) && |
|
132 | - $theClass !== '' && |
|
133 | - \class_exists($theClass, false)) { |
|
134 | - $argumentsValid = true; |
|
135 | - |
|
136 | - if ($name == '') { |
|
137 | - $name = $theClass; |
|
138 | - } |
|
139 | - |
|
140 | - $theClass = new ReflectionClass($theClass); |
|
141 | - } elseif (\is_string($theClass)) { |
|
142 | - $this->setName($theClass); |
|
143 | - |
|
144 | - return; |
|
145 | - } |
|
146 | - |
|
147 | - if (!$argumentsValid) { |
|
148 | - throw new Exception; |
|
149 | - } |
|
150 | - |
|
151 | - if (!$theClass->isSubclassOf(TestCase::class)) { |
|
152 | - throw new Exception( |
|
153 | - 'Class "' . $theClass->name . '" does not extend PHPUnit\Framework\TestCase.' |
|
154 | - ); |
|
155 | - } |
|
156 | - |
|
157 | - if ($name != '') { |
|
158 | - $this->setName($name); |
|
159 | - } else { |
|
160 | - $this->setName($theClass->getName()); |
|
161 | - } |
|
162 | - |
|
163 | - $constructor = $theClass->getConstructor(); |
|
164 | - |
|
165 | - if ($constructor !== null && |
|
166 | - !$constructor->isPublic()) { |
|
167 | - $this->addTest( |
|
168 | - self::warning( |
|
169 | - \sprintf( |
|
170 | - 'Class "%s" has no public constructor.', |
|
171 | - $theClass->getName() |
|
172 | - ) |
|
173 | - ) |
|
174 | - ); |
|
175 | - |
|
176 | - return; |
|
177 | - } |
|
178 | - |
|
179 | - foreach ($theClass->getMethods() as $method) { |
|
180 | - $this->addTestMethod($theClass, $method); |
|
181 | - } |
|
182 | - |
|
183 | - if (empty($this->tests)) { |
|
184 | - $this->addTest( |
|
185 | - self::warning( |
|
186 | - \sprintf( |
|
187 | - 'No tests found in class "%s".', |
|
188 | - $theClass->getName() |
|
189 | - ) |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - $this->testCase = true; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Returns a string representation of the test suite. |
|
199 | - * |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function toString() |
|
203 | - { |
|
204 | - return $this->getName(); |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Adds a test to the suite. |
|
209 | - * |
|
210 | - * @param Test $test |
|
211 | - * @param array $groups |
|
212 | - */ |
|
213 | - public function addTest(Test $test, $groups = []) |
|
214 | - { |
|
215 | - $class = new ReflectionClass($test); |
|
216 | - |
|
217 | - if (!$class->isAbstract()) { |
|
218 | - $this->tests[] = $test; |
|
219 | - $this->numTests = -1; |
|
220 | - |
|
221 | - if ($test instanceof self && empty($groups)) { |
|
222 | - $groups = $test->getGroups(); |
|
223 | - } |
|
224 | - |
|
225 | - if (empty($groups)) { |
|
226 | - $groups = ['default']; |
|
227 | - } |
|
228 | - |
|
229 | - foreach ($groups as $group) { |
|
230 | - if (!isset($this->groups[$group])) { |
|
231 | - $this->groups[$group] = [$test]; |
|
232 | - } else { |
|
233 | - $this->groups[$group][] = $test; |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - if ($test instanceof TestCase) { |
|
238 | - $test->setGroups($groups); |
|
239 | - } |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Adds the tests from the given class to the suite. |
|
245 | - * |
|
246 | - * @param mixed $testClass |
|
247 | - * |
|
248 | - * @throws Exception |
|
249 | - */ |
|
250 | - public function addTestSuite($testClass) |
|
251 | - { |
|
252 | - if (\is_string($testClass) && \class_exists($testClass)) { |
|
253 | - $testClass = new ReflectionClass($testClass); |
|
254 | - } |
|
255 | - |
|
256 | - if (!\is_object($testClass)) { |
|
257 | - throw InvalidArgumentHelper::factory( |
|
258 | - 1, |
|
259 | - 'class name or object' |
|
260 | - ); |
|
261 | - } |
|
262 | - |
|
263 | - if ($testClass instanceof self) { |
|
264 | - $this->addTest($testClass); |
|
265 | - } elseif ($testClass instanceof ReflectionClass) { |
|
266 | - $suiteMethod = false; |
|
267 | - |
|
268 | - if (!$testClass->isAbstract() && $testClass->hasMethod(BaseTestRunner::SUITE_METHODNAME)) { |
|
269 | - $method = $testClass->getMethod( |
|
270 | - BaseTestRunner::SUITE_METHODNAME |
|
271 | - ); |
|
272 | - |
|
273 | - if ($method->isStatic()) { |
|
274 | - $this->addTest( |
|
275 | - $method->invoke(null, $testClass->getName()) |
|
276 | - ); |
|
277 | - |
|
278 | - $suiteMethod = true; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - if (!$suiteMethod && !$testClass->isAbstract()) { |
|
283 | - $this->addTest(new self($testClass)); |
|
284 | - } |
|
285 | - } else { |
|
286 | - throw new Exception; |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Wraps both <code>addTest()</code> and <code>addTestSuite</code> |
|
292 | - * as well as the separate import statements for the user's convenience. |
|
293 | - * |
|
294 | - * If the named file cannot be read or there are no new tests that can be |
|
295 | - * added, a <code>PHPUnit\Framework\WarningTestCase</code> will be created instead, |
|
296 | - * leaving the current test run untouched. |
|
297 | - * |
|
298 | - * @param string $filename |
|
299 | - * |
|
300 | - * @throws Exception |
|
301 | - */ |
|
302 | - public function addTestFile($filename) |
|
303 | - { |
|
304 | - if (!\is_string($filename)) { |
|
305 | - throw InvalidArgumentHelper::factory(1, 'string'); |
|
306 | - } |
|
307 | - |
|
308 | - if (\file_exists($filename) && \substr($filename, -5) == '.phpt') { |
|
309 | - $this->addTest( |
|
310 | - new PhptTestCase($filename) |
|
311 | - ); |
|
312 | - |
|
313 | - return; |
|
314 | - } |
|
315 | - |
|
316 | - // The given file may contain further stub classes in addition to the |
|
317 | - // test class itself. Figure out the actual test class. |
|
318 | - $classes = \get_declared_classes(); |
|
319 | - $filename = Fileloader::checkAndLoad($filename); |
|
320 | - $newClasses = \array_diff(\get_declared_classes(), $classes); |
|
321 | - |
|
322 | - // The diff is empty in case a parent class (with test methods) is added |
|
323 | - // AFTER a child class that inherited from it. To account for that case, |
|
324 | - // accumulate all discovered classes, so the parent class may be found in |
|
325 | - // a later invocation. |
|
326 | - if (!empty($newClasses)) { |
|
327 | - // On the assumption that test classes are defined first in files, |
|
328 | - // process discovered classes in approximate LIFO order, so as to |
|
329 | - // avoid unnecessary reflection. |
|
330 | - $this->foundClasses = \array_merge($newClasses, $this->foundClasses); |
|
331 | - } |
|
332 | - |
|
333 | - // The test class's name must match the filename, either in full, or as |
|
334 | - // a PEAR/PSR-0 prefixed shortname ('NameSpace_ShortName'), or as a |
|
335 | - // PSR-1 local shortname ('NameSpace\ShortName'). The comparison must be |
|
336 | - // anchored to prevent false-positive matches (e.g., 'OtherShortName'). |
|
337 | - $shortname = \basename($filename, '.php'); |
|
338 | - $shortnameRegEx = '/(?:^|_|\\\\)' . \preg_quote($shortname, '/') . '$/'; |
|
339 | - |
|
340 | - foreach ($this->foundClasses as $i => $className) { |
|
341 | - if (\preg_match($shortnameRegEx, $className)) { |
|
342 | - $class = new ReflectionClass($className); |
|
343 | - |
|
344 | - if ($class->getFileName() == $filename) { |
|
345 | - $newClasses = [$className]; |
|
346 | - unset($this->foundClasses[$i]); |
|
347 | - |
|
348 | - break; |
|
349 | - } |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - foreach ($newClasses as $className) { |
|
354 | - $class = new ReflectionClass($className); |
|
355 | - |
|
356 | - if (!$class->isAbstract()) { |
|
357 | - if ($class->hasMethod(BaseTestRunner::SUITE_METHODNAME)) { |
|
358 | - $method = $class->getMethod( |
|
359 | - BaseTestRunner::SUITE_METHODNAME |
|
360 | - ); |
|
361 | - |
|
362 | - if ($method->isStatic()) { |
|
363 | - $this->addTest($method->invoke(null, $className)); |
|
364 | - } |
|
365 | - } elseif ($class->implementsInterface(Test::class)) { |
|
366 | - $this->addTestSuite($class); |
|
367 | - } |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - $this->numTests = -1; |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Wrapper for addTestFile() that adds multiple test files. |
|
376 | - * |
|
377 | - * @param array|Iterator $filenames |
|
378 | - * |
|
379 | - * @throws Exception |
|
380 | - */ |
|
381 | - public function addTestFiles($filenames) |
|
382 | - { |
|
383 | - if (!(\is_array($filenames) || |
|
384 | - (\is_object($filenames) && $filenames instanceof Iterator))) { |
|
385 | - throw InvalidArgumentHelper::factory( |
|
386 | - 1, |
|
387 | - 'array or iterator' |
|
388 | - ); |
|
389 | - } |
|
390 | - |
|
391 | - foreach ($filenames as $filename) { |
|
392 | - $this->addTestFile((string) $filename); |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Counts the number of test cases that will be run by this test. |
|
398 | - * |
|
399 | - * @param bool $preferCache Indicates if cache is preferred. |
|
400 | - * |
|
401 | - * @return int |
|
402 | - */ |
|
403 | - public function count($preferCache = false) |
|
404 | - { |
|
405 | - if ($preferCache && $this->cachedNumTests !== null) { |
|
406 | - return $this->cachedNumTests; |
|
407 | - } |
|
408 | - |
|
409 | - $numTests = 0; |
|
410 | - |
|
411 | - foreach ($this as $test) { |
|
412 | - $numTests += \count($test); |
|
413 | - } |
|
414 | - |
|
415 | - $this->cachedNumTests = $numTests; |
|
416 | - |
|
417 | - return $numTests; |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * @param ReflectionClass $theClass |
|
422 | - * @param string $name |
|
423 | - * |
|
424 | - * @return Test |
|
425 | - * |
|
426 | - * @throws Exception |
|
427 | - */ |
|
428 | - public static function createTest(ReflectionClass $theClass, $name) |
|
429 | - { |
|
430 | - $className = $theClass->getName(); |
|
431 | - |
|
432 | - if (!$theClass->isInstantiable()) { |
|
433 | - return self::warning( |
|
434 | - \sprintf('Cannot instantiate class "%s".', $className) |
|
435 | - ); |
|
436 | - } |
|
437 | - |
|
438 | - $backupSettings = \PHPUnit\Util\Test::getBackupSettings( |
|
439 | - $className, |
|
440 | - $name |
|
441 | - ); |
|
442 | - |
|
443 | - $preserveGlobalState = \PHPUnit\Util\Test::getPreserveGlobalStateSettings( |
|
444 | - $className, |
|
445 | - $name |
|
446 | - ); |
|
447 | - |
|
448 | - $runTestInSeparateProcess = \PHPUnit\Util\Test::getProcessIsolationSettings( |
|
449 | - $className, |
|
450 | - $name |
|
451 | - ); |
|
452 | - |
|
453 | - $runClassInSeparateProcess = \PHPUnit\Util\Test::getClassProcessIsolationSettings( |
|
454 | - $className, |
|
455 | - $name |
|
456 | - ); |
|
457 | - |
|
458 | - $constructor = $theClass->getConstructor(); |
|
459 | - |
|
460 | - if ($constructor !== null) { |
|
461 | - $parameters = $constructor->getParameters(); |
|
462 | - |
|
463 | - // TestCase() or TestCase($name) |
|
464 | - if (\count($parameters) < 2) { |
|
465 | - $test = new $className; |
|
466 | - } // TestCase($name, $data) |
|
467 | - else { |
|
468 | - try { |
|
469 | - $data = \PHPUnit\Util\Test::getProvidedData( |
|
470 | - $className, |
|
471 | - $name |
|
472 | - ); |
|
473 | - } catch (IncompleteTestError $e) { |
|
474 | - $message = \sprintf( |
|
475 | - 'Test for %s::%s marked incomplete by data provider', |
|
476 | - $className, |
|
477 | - $name |
|
478 | - ); |
|
479 | - |
|
480 | - $_message = $e->getMessage(); |
|
481 | - |
|
482 | - if (!empty($_message)) { |
|
483 | - $message .= "\n" . $_message; |
|
484 | - } |
|
485 | - |
|
486 | - $data = self::incompleteTest($className, $name, $message); |
|
487 | - } catch (SkippedTestError $e) { |
|
488 | - $message = \sprintf( |
|
489 | - 'Test for %s::%s skipped by data provider', |
|
490 | - $className, |
|
491 | - $name |
|
492 | - ); |
|
493 | - |
|
494 | - $_message = $e->getMessage(); |
|
495 | - |
|
496 | - if (!empty($_message)) { |
|
497 | - $message .= "\n" . $_message; |
|
498 | - } |
|
499 | - |
|
500 | - $data = self::skipTest($className, $name, $message); |
|
501 | - } catch (Throwable $_t) { |
|
502 | - $t = $_t; |
|
503 | - } catch (Exception $_t) { |
|
504 | - $t = $_t; |
|
505 | - } |
|
506 | - |
|
507 | - if (isset($t)) { |
|
508 | - $message = \sprintf( |
|
509 | - 'The data provider specified for %s::%s is invalid.', |
|
510 | - $className, |
|
511 | - $name |
|
512 | - ); |
|
513 | - |
|
514 | - $_message = $t->getMessage(); |
|
515 | - |
|
516 | - if (!empty($_message)) { |
|
517 | - $message .= "\n" . $_message; |
|
518 | - } |
|
519 | - |
|
520 | - $data = self::warning($message); |
|
521 | - } |
|
522 | - |
|
523 | - // Test method with @dataProvider. |
|
524 | - if (isset($data)) { |
|
525 | - $test = new DataProviderTestSuite( |
|
526 | - $className . '::' . $name |
|
527 | - ); |
|
528 | - |
|
529 | - if (empty($data)) { |
|
530 | - $data = self::warning( |
|
531 | - \sprintf( |
|
532 | - 'No tests found in suite "%s".', |
|
533 | - $test->getName() |
|
534 | - ) |
|
535 | - ); |
|
536 | - } |
|
537 | - |
|
538 | - $groups = \PHPUnit\Util\Test::getGroups($className, $name); |
|
539 | - |
|
540 | - if ($data instanceof WarningTestCase || |
|
541 | - $data instanceof SkippedTestCase || |
|
542 | - $data instanceof IncompleteTestCase) { |
|
543 | - $test->addTest($data, $groups); |
|
544 | - } else { |
|
545 | - foreach ($data as $_dataName => $_data) { |
|
546 | - $_test = new $className($name, $_data, $_dataName); |
|
547 | - |
|
548 | - if ($runTestInSeparateProcess) { |
|
549 | - $_test->setRunTestInSeparateProcess(true); |
|
550 | - |
|
551 | - if ($preserveGlobalState !== null) { |
|
552 | - $_test->setPreserveGlobalState($preserveGlobalState); |
|
553 | - } |
|
554 | - } |
|
555 | - |
|
556 | - if ($runClassInSeparateProcess) { |
|
557 | - $_test->setRunClassInSeparateProcess(true); |
|
558 | - |
|
559 | - if ($preserveGlobalState !== null) { |
|
560 | - $_test->setPreserveGlobalState($preserveGlobalState); |
|
561 | - } |
|
562 | - } |
|
563 | - |
|
564 | - if ($backupSettings['backupGlobals'] !== null) { |
|
565 | - $_test->setBackupGlobals( |
|
566 | - $backupSettings['backupGlobals'] |
|
567 | - ); |
|
568 | - } |
|
569 | - |
|
570 | - if ($backupSettings['backupStaticAttributes'] !== null) { |
|
571 | - $_test->setBackupStaticAttributes( |
|
572 | - $backupSettings['backupStaticAttributes'] |
|
573 | - ); |
|
574 | - } |
|
575 | - |
|
576 | - $test->addTest($_test, $groups); |
|
577 | - } |
|
578 | - } |
|
579 | - } else { |
|
580 | - $test = new $className; |
|
581 | - } |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - if (!isset($test)) { |
|
586 | - throw new Exception('No valid test provided.'); |
|
587 | - } |
|
588 | - |
|
589 | - if ($test instanceof TestCase) { |
|
590 | - $test->setName($name); |
|
591 | - |
|
592 | - if ($runTestInSeparateProcess) { |
|
593 | - $test->setRunTestInSeparateProcess(true); |
|
594 | - |
|
595 | - if ($preserveGlobalState !== null) { |
|
596 | - $test->setPreserveGlobalState($preserveGlobalState); |
|
597 | - } |
|
598 | - } |
|
599 | - |
|
600 | - if ($backupSettings['backupGlobals'] !== null) { |
|
601 | - $test->setBackupGlobals($backupSettings['backupGlobals']); |
|
602 | - } |
|
603 | - |
|
604 | - if ($backupSettings['backupStaticAttributes'] !== null) { |
|
605 | - $test->setBackupStaticAttributes( |
|
606 | - $backupSettings['backupStaticAttributes'] |
|
607 | - ); |
|
608 | - } |
|
609 | - } |
|
610 | - |
|
611 | - return $test; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Creates a default TestResult object. |
|
616 | - * |
|
617 | - * @return TestResult |
|
618 | - */ |
|
619 | - protected function createResult() |
|
620 | - { |
|
621 | - return new TestResult; |
|
622 | - } |
|
623 | - |
|
624 | - /** |
|
625 | - * Returns the name of the suite. |
|
626 | - * |
|
627 | - * @return string |
|
628 | - */ |
|
629 | - public function getName() |
|
630 | - { |
|
631 | - return $this->name; |
|
632 | - } |
|
633 | - |
|
634 | - /** |
|
635 | - * Returns the test groups of the suite. |
|
636 | - * |
|
637 | - * @return array |
|
638 | - */ |
|
639 | - public function getGroups() |
|
640 | - { |
|
641 | - return \array_keys($this->groups); |
|
642 | - } |
|
643 | - |
|
644 | - public function getGroupDetails() |
|
645 | - { |
|
646 | - return $this->groups; |
|
647 | - } |
|
648 | - |
|
649 | - /** |
|
650 | - * Set tests groups of the test case |
|
651 | - * |
|
652 | - * @param array $groups |
|
653 | - */ |
|
654 | - public function setGroupDetails(array $groups) |
|
655 | - { |
|
656 | - $this->groups = $groups; |
|
657 | - } |
|
658 | - |
|
659 | - /** |
|
660 | - * Runs the tests and collects their result in a TestResult. |
|
661 | - * |
|
662 | - * @param TestResult $result |
|
663 | - * |
|
664 | - * @return TestResult |
|
665 | - */ |
|
666 | - public function run(TestResult $result = null) |
|
667 | - { |
|
668 | - if ($result === null) { |
|
669 | - $result = $this->createResult(); |
|
670 | - } |
|
671 | - |
|
672 | - if (\count($this) == 0) { |
|
673 | - return $result; |
|
674 | - } |
|
675 | - |
|
676 | - $hookMethods = \PHPUnit\Util\Test::getHookMethods($this->name); |
|
677 | - |
|
678 | - $result->startTestSuite($this); |
|
679 | - |
|
680 | - try { |
|
681 | - $this->setUp(); |
|
682 | - |
|
683 | - foreach ($hookMethods['beforeClass'] as $beforeClassMethod) { |
|
684 | - if ($this->testCase === true && |
|
685 | - \class_exists($this->name, false) && |
|
686 | - \method_exists($this->name, $beforeClassMethod)) { |
|
687 | - if ($missingRequirements = \PHPUnit\Util\Test::getMissingRequirements($this->name, $beforeClassMethod)) { |
|
688 | - $this->markTestSuiteSkipped(\implode(PHP_EOL, $missingRequirements)); |
|
689 | - } |
|
690 | - |
|
691 | - \call_user_func([$this->name, $beforeClassMethod]); |
|
692 | - } |
|
693 | - } |
|
694 | - } catch (SkippedTestSuiteError $e) { |
|
695 | - $numTests = \count($this); |
|
696 | - |
|
697 | - for ($i = 0; $i < $numTests; $i++) { |
|
698 | - $result->startTest($this); |
|
699 | - $result->addFailure($this, $e, 0); |
|
700 | - $result->endTest($this, 0); |
|
701 | - } |
|
702 | - |
|
703 | - $this->tearDown(); |
|
704 | - $result->endTestSuite($this); |
|
705 | - |
|
706 | - return $result; |
|
707 | - } catch (Throwable $_t) { |
|
708 | - $t = $_t; |
|
709 | - } catch (Exception $_t) { |
|
710 | - $t = $_t; |
|
711 | - } |
|
712 | - |
|
713 | - if (isset($t)) { |
|
714 | - $numTests = \count($this); |
|
715 | - |
|
716 | - for ($i = 0; $i < $numTests; $i++) { |
|
717 | - if ($result->shouldStop()) { |
|
718 | - break; |
|
719 | - } |
|
720 | - |
|
721 | - $result->startTest($this); |
|
722 | - $result->addError($this, $t, 0); |
|
723 | - $result->endTest($this, 0); |
|
724 | - } |
|
725 | - |
|
726 | - $this->tearDown(); |
|
727 | - $result->endTestSuite($this); |
|
728 | - |
|
729 | - return $result; |
|
730 | - } |
|
731 | - |
|
732 | - foreach ($this as $test) { |
|
733 | - if ($result->shouldStop()) { |
|
734 | - break; |
|
735 | - } |
|
736 | - |
|
737 | - if ($test instanceof TestCase || $test instanceof self) { |
|
738 | - $test->setbeStrictAboutChangesToGlobalState($this->beStrictAboutChangesToGlobalState); |
|
739 | - $test->setBackupGlobals($this->backupGlobals); |
|
740 | - $test->setBackupStaticAttributes($this->backupStaticAttributes); |
|
741 | - $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess); |
|
742 | - } |
|
743 | - |
|
744 | - $test->run($result); |
|
745 | - } |
|
746 | - |
|
747 | - foreach ($hookMethods['afterClass'] as $afterClassMethod) { |
|
748 | - if ($this->testCase === true && \class_exists($this->name, false) && \method_exists($this->name, $afterClassMethod)) { |
|
749 | - \call_user_func([$this->name, $afterClassMethod]); |
|
750 | - } |
|
751 | - } |
|
752 | - |
|
753 | - $this->tearDown(); |
|
754 | - |
|
755 | - $result->endTestSuite($this); |
|
756 | - |
|
757 | - return $result; |
|
758 | - } |
|
759 | - |
|
760 | - /** |
|
761 | - * @param bool $runTestInSeparateProcess |
|
762 | - * |
|
763 | - * @throws Exception |
|
764 | - */ |
|
765 | - public function setRunTestInSeparateProcess($runTestInSeparateProcess) |
|
766 | - { |
|
767 | - if (\is_bool($runTestInSeparateProcess)) { |
|
768 | - $this->runTestInSeparateProcess = $runTestInSeparateProcess; |
|
769 | - } else { |
|
770 | - throw InvalidArgumentHelper::factory(1, 'boolean'); |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - /** |
|
775 | - * Runs a test. |
|
776 | - * |
|
777 | - * @deprecated |
|
778 | - * |
|
779 | - * @param Test $test |
|
780 | - * @param TestResult $result |
|
781 | - */ |
|
782 | - public function runTest(Test $test, TestResult $result) |
|
783 | - { |
|
784 | - $test->run($result); |
|
785 | - } |
|
786 | - |
|
787 | - /** |
|
788 | - * Sets the name of the suite. |
|
789 | - * |
|
790 | - * @param string |
|
791 | - */ |
|
792 | - public function setName($name) |
|
793 | - { |
|
794 | - $this->name = $name; |
|
795 | - } |
|
796 | - |
|
797 | - /** |
|
798 | - * Returns the test at the given index. |
|
799 | - * |
|
800 | - * @param int|false |
|
801 | - * |
|
802 | - * @return Test|false |
|
803 | - */ |
|
804 | - public function testAt($index) |
|
805 | - { |
|
806 | - if (isset($this->tests[$index])) { |
|
807 | - return $this->tests[$index]; |
|
808 | - } |
|
809 | - |
|
810 | - return false; |
|
811 | - } |
|
812 | - |
|
813 | - /** |
|
814 | - * Returns the tests as an enumeration. |
|
815 | - * |
|
816 | - * @return array |
|
817 | - */ |
|
818 | - public function tests() |
|
819 | - { |
|
820 | - return $this->tests; |
|
821 | - } |
|
822 | - |
|
823 | - /** |
|
824 | - * Set tests of the test suite |
|
825 | - * |
|
826 | - * @param array $tests |
|
827 | - */ |
|
828 | - public function setTests(array $tests) |
|
829 | - { |
|
830 | - $this->tests = $tests; |
|
831 | - } |
|
832 | - |
|
833 | - /** |
|
834 | - * Mark the test suite as skipped. |
|
835 | - * |
|
836 | - * @param string $message |
|
837 | - * |
|
838 | - * @throws SkippedTestSuiteError |
|
839 | - */ |
|
840 | - public function markTestSuiteSkipped($message = '') |
|
841 | - { |
|
842 | - throw new SkippedTestSuiteError($message); |
|
843 | - } |
|
844 | - |
|
845 | - /** |
|
846 | - * @param ReflectionClass $class |
|
847 | - * @param ReflectionMethod $method |
|
848 | - */ |
|
849 | - protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method) |
|
850 | - { |
|
851 | - if (!$this->isTestMethod($method)) { |
|
852 | - return; |
|
853 | - } |
|
854 | - |
|
855 | - $name = $method->getName(); |
|
856 | - |
|
857 | - if (!$method->isPublic()) { |
|
858 | - $this->addTest( |
|
859 | - self::warning( |
|
860 | - \sprintf( |
|
861 | - 'Test method "%s" in test class "%s" is not public.', |
|
862 | - $name, |
|
863 | - $class->getName() |
|
864 | - ) |
|
865 | - ) |
|
866 | - ); |
|
867 | - |
|
868 | - return; |
|
869 | - } |
|
870 | - |
|
871 | - $test = self::createTest($class, $name); |
|
872 | - |
|
873 | - if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) { |
|
874 | - $test->setDependencies( |
|
875 | - \PHPUnit\Util\Test::getDependencies($class->getName(), $name) |
|
876 | - ); |
|
877 | - } |
|
878 | - |
|
879 | - $this->addTest( |
|
880 | - $test, |
|
881 | - \PHPUnit\Util\Test::getGroups($class->getName(), $name) |
|
882 | - ); |
|
883 | - } |
|
884 | - |
|
885 | - /** |
|
886 | - * @param ReflectionMethod $method |
|
887 | - * |
|
888 | - * @return bool |
|
889 | - */ |
|
890 | - public static function isTestMethod(ReflectionMethod $method) |
|
891 | - { |
|
892 | - if (\strpos($method->name, 'test') === 0) { |
|
893 | - return true; |
|
894 | - } |
|
895 | - |
|
896 | - // @scenario on TestCase::testMethod() |
|
897 | - // @test on TestCase::testMethod() |
|
898 | - $docComment = $method->getDocComment(); |
|
899 | - |
|
900 | - return \strpos($docComment, '@test') !== false || |
|
901 | - \strpos($docComment, '@scenario') !== false; |
|
902 | - } |
|
903 | - |
|
904 | - /** |
|
905 | - * @param string $message |
|
906 | - * |
|
907 | - * @return WarningTestCase |
|
908 | - */ |
|
909 | - protected static function warning($message) |
|
910 | - { |
|
911 | - return new WarningTestCase($message); |
|
912 | - } |
|
913 | - |
|
914 | - /** |
|
915 | - * @param string $class |
|
916 | - * @param string $methodName |
|
917 | - * @param string $message |
|
918 | - * |
|
919 | - * @return SkippedTestCase |
|
920 | - */ |
|
921 | - protected static function skipTest($class, $methodName, $message) |
|
922 | - { |
|
923 | - return new SkippedTestCase($class, $methodName, $message); |
|
924 | - } |
|
925 | - |
|
926 | - /** |
|
927 | - * @param string $class |
|
928 | - * @param string $methodName |
|
929 | - * @param string $message |
|
930 | - * |
|
931 | - * @return IncompleteTestCase |
|
932 | - */ |
|
933 | - protected static function incompleteTest($class, $methodName, $message) |
|
934 | - { |
|
935 | - return new IncompleteTestCase($class, $methodName, $message); |
|
936 | - } |
|
937 | - |
|
938 | - /** |
|
939 | - * @param bool $beStrictAboutChangesToGlobalState |
|
940 | - */ |
|
941 | - public function setbeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlobalState) |
|
942 | - { |
|
943 | - if (null === $this->beStrictAboutChangesToGlobalState && \is_bool($beStrictAboutChangesToGlobalState)) { |
|
944 | - $this->beStrictAboutChangesToGlobalState = $beStrictAboutChangesToGlobalState; |
|
945 | - } |
|
946 | - } |
|
947 | - |
|
948 | - /** |
|
949 | - * @param bool $backupGlobals |
|
950 | - */ |
|
951 | - public function setBackupGlobals($backupGlobals) |
|
952 | - { |
|
953 | - if (null === $this->backupGlobals && \is_bool($backupGlobals)) { |
|
954 | - $this->backupGlobals = $backupGlobals; |
|
955 | - } |
|
956 | - } |
|
957 | - |
|
958 | - /** |
|
959 | - * @param bool $backupStaticAttributes |
|
960 | - */ |
|
961 | - public function setBackupStaticAttributes($backupStaticAttributes) |
|
962 | - { |
|
963 | - if (null === $this->backupStaticAttributes && \is_bool($backupStaticAttributes)) { |
|
964 | - $this->backupStaticAttributes = $backupStaticAttributes; |
|
965 | - } |
|
966 | - } |
|
967 | - |
|
968 | - /** |
|
969 | - * Returns an iterator for this test suite. |
|
970 | - * |
|
971 | - * @return TestSuiteIterator |
|
972 | - */ |
|
973 | - public function getIterator() |
|
974 | - { |
|
975 | - $iterator = new TestSuiteIterator($this); |
|
976 | - |
|
977 | - if ($this->iteratorFilter !== null) { |
|
978 | - $iterator = $this->iteratorFilter->factory($iterator, $this); |
|
979 | - } |
|
980 | - |
|
981 | - return $iterator; |
|
982 | - } |
|
983 | - |
|
984 | - public function injectFilter(Factory $filter) |
|
985 | - { |
|
986 | - $this->iteratorFilter = $filter; |
|
987 | - foreach ($this as $test) { |
|
988 | - if ($test instanceof self) { |
|
989 | - $test->injectFilter($filter); |
|
990 | - } |
|
991 | - } |
|
992 | - } |
|
993 | - |
|
994 | - /** |
|
995 | - * Template Method that is called before the tests |
|
996 | - * of this test suite are run. |
|
997 | - */ |
|
998 | - protected function setUp() |
|
999 | - { |
|
1000 | - } |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * Template Method that is called after the tests |
|
1004 | - * of this test suite have finished running. |
|
1005 | - */ |
|
1006 | - protected function tearDown() |
|
1007 | - { |
|
1008 | - } |
|
28 | + /** |
|
29 | + * Last count of tests in this suite. |
|
30 | + * |
|
31 | + * @var int|null |
|
32 | + */ |
|
33 | + private $cachedNumTests; |
|
34 | + |
|
35 | + /** |
|
36 | + * Enable or disable the backup and restoration of the $GLOBALS array. |
|
37 | + * |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | + protected $backupGlobals; |
|
41 | + |
|
42 | + /** |
|
43 | + * Enable or disable the backup and restoration of static attributes. |
|
44 | + * |
|
45 | + * @var bool |
|
46 | + */ |
|
47 | + protected $backupStaticAttributes; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | + private $beStrictAboutChangesToGlobalState; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var bool |
|
56 | + */ |
|
57 | + protected $runTestInSeparateProcess = false; |
|
58 | + |
|
59 | + /** |
|
60 | + * The name of the test suite. |
|
61 | + * |
|
62 | + * @var string |
|
63 | + */ |
|
64 | + protected $name = ''; |
|
65 | + |
|
66 | + /** |
|
67 | + * The test groups of the test suite. |
|
68 | + * |
|
69 | + * @var array |
|
70 | + */ |
|
71 | + protected $groups = []; |
|
72 | + |
|
73 | + /** |
|
74 | + * The tests in the test suite. |
|
75 | + * |
|
76 | + * @var TestCase[] |
|
77 | + */ |
|
78 | + protected $tests = []; |
|
79 | + |
|
80 | + /** |
|
81 | + * The number of tests in the test suite. |
|
82 | + * |
|
83 | + * @var int |
|
84 | + */ |
|
85 | + protected $numTests = -1; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var bool |
|
89 | + */ |
|
90 | + protected $testCase = false; |
|
91 | + |
|
92 | + /** |
|
93 | + * @var array |
|
94 | + */ |
|
95 | + protected $foundClasses = []; |
|
96 | + |
|
97 | + /** |
|
98 | + * @var Factory |
|
99 | + */ |
|
100 | + private $iteratorFilter; |
|
101 | + |
|
102 | + /** |
|
103 | + * Constructs a new TestSuite: |
|
104 | + * |
|
105 | + * - PHPUnit\Framework\TestSuite() constructs an empty TestSuite. |
|
106 | + * |
|
107 | + * - PHPUnit\Framework\TestSuite(ReflectionClass) constructs a |
|
108 | + * TestSuite from the given class. |
|
109 | + * |
|
110 | + * - PHPUnit\Framework\TestSuite(ReflectionClass, String) |
|
111 | + * constructs a TestSuite from the given class with the given |
|
112 | + * name. |
|
113 | + * |
|
114 | + * - PHPUnit\Framework\TestSuite(String) either constructs a |
|
115 | + * TestSuite from the given class (if the passed string is the |
|
116 | + * name of an existing class) or constructs an empty TestSuite |
|
117 | + * with the given name. |
|
118 | + * |
|
119 | + * @param mixed $theClass |
|
120 | + * @param string $name |
|
121 | + * |
|
122 | + * @throws Exception |
|
123 | + */ |
|
124 | + public function __construct($theClass = '', $name = '') |
|
125 | + { |
|
126 | + $argumentsValid = false; |
|
127 | + |
|
128 | + if (\is_object($theClass) && |
|
129 | + $theClass instanceof ReflectionClass) { |
|
130 | + $argumentsValid = true; |
|
131 | + } elseif (\is_string($theClass) && |
|
132 | + $theClass !== '' && |
|
133 | + \class_exists($theClass, false)) { |
|
134 | + $argumentsValid = true; |
|
135 | + |
|
136 | + if ($name == '') { |
|
137 | + $name = $theClass; |
|
138 | + } |
|
139 | + |
|
140 | + $theClass = new ReflectionClass($theClass); |
|
141 | + } elseif (\is_string($theClass)) { |
|
142 | + $this->setName($theClass); |
|
143 | + |
|
144 | + return; |
|
145 | + } |
|
146 | + |
|
147 | + if (!$argumentsValid) { |
|
148 | + throw new Exception; |
|
149 | + } |
|
150 | + |
|
151 | + if (!$theClass->isSubclassOf(TestCase::class)) { |
|
152 | + throw new Exception( |
|
153 | + 'Class "' . $theClass->name . '" does not extend PHPUnit\Framework\TestCase.' |
|
154 | + ); |
|
155 | + } |
|
156 | + |
|
157 | + if ($name != '') { |
|
158 | + $this->setName($name); |
|
159 | + } else { |
|
160 | + $this->setName($theClass->getName()); |
|
161 | + } |
|
162 | + |
|
163 | + $constructor = $theClass->getConstructor(); |
|
164 | + |
|
165 | + if ($constructor !== null && |
|
166 | + !$constructor->isPublic()) { |
|
167 | + $this->addTest( |
|
168 | + self::warning( |
|
169 | + \sprintf( |
|
170 | + 'Class "%s" has no public constructor.', |
|
171 | + $theClass->getName() |
|
172 | + ) |
|
173 | + ) |
|
174 | + ); |
|
175 | + |
|
176 | + return; |
|
177 | + } |
|
178 | + |
|
179 | + foreach ($theClass->getMethods() as $method) { |
|
180 | + $this->addTestMethod($theClass, $method); |
|
181 | + } |
|
182 | + |
|
183 | + if (empty($this->tests)) { |
|
184 | + $this->addTest( |
|
185 | + self::warning( |
|
186 | + \sprintf( |
|
187 | + 'No tests found in class "%s".', |
|
188 | + $theClass->getName() |
|
189 | + ) |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + $this->testCase = true; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Returns a string representation of the test suite. |
|
199 | + * |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function toString() |
|
203 | + { |
|
204 | + return $this->getName(); |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Adds a test to the suite. |
|
209 | + * |
|
210 | + * @param Test $test |
|
211 | + * @param array $groups |
|
212 | + */ |
|
213 | + public function addTest(Test $test, $groups = []) |
|
214 | + { |
|
215 | + $class = new ReflectionClass($test); |
|
216 | + |
|
217 | + if (!$class->isAbstract()) { |
|
218 | + $this->tests[] = $test; |
|
219 | + $this->numTests = -1; |
|
220 | + |
|
221 | + if ($test instanceof self && empty($groups)) { |
|
222 | + $groups = $test->getGroups(); |
|
223 | + } |
|
224 | + |
|
225 | + if (empty($groups)) { |
|
226 | + $groups = ['default']; |
|
227 | + } |
|
228 | + |
|
229 | + foreach ($groups as $group) { |
|
230 | + if (!isset($this->groups[$group])) { |
|
231 | + $this->groups[$group] = [$test]; |
|
232 | + } else { |
|
233 | + $this->groups[$group][] = $test; |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + if ($test instanceof TestCase) { |
|
238 | + $test->setGroups($groups); |
|
239 | + } |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Adds the tests from the given class to the suite. |
|
245 | + * |
|
246 | + * @param mixed $testClass |
|
247 | + * |
|
248 | + * @throws Exception |
|
249 | + */ |
|
250 | + public function addTestSuite($testClass) |
|
251 | + { |
|
252 | + if (\is_string($testClass) && \class_exists($testClass)) { |
|
253 | + $testClass = new ReflectionClass($testClass); |
|
254 | + } |
|
255 | + |
|
256 | + if (!\is_object($testClass)) { |
|
257 | + throw InvalidArgumentHelper::factory( |
|
258 | + 1, |
|
259 | + 'class name or object' |
|
260 | + ); |
|
261 | + } |
|
262 | + |
|
263 | + if ($testClass instanceof self) { |
|
264 | + $this->addTest($testClass); |
|
265 | + } elseif ($testClass instanceof ReflectionClass) { |
|
266 | + $suiteMethod = false; |
|
267 | + |
|
268 | + if (!$testClass->isAbstract() && $testClass->hasMethod(BaseTestRunner::SUITE_METHODNAME)) { |
|
269 | + $method = $testClass->getMethod( |
|
270 | + BaseTestRunner::SUITE_METHODNAME |
|
271 | + ); |
|
272 | + |
|
273 | + if ($method->isStatic()) { |
|
274 | + $this->addTest( |
|
275 | + $method->invoke(null, $testClass->getName()) |
|
276 | + ); |
|
277 | + |
|
278 | + $suiteMethod = true; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + if (!$suiteMethod && !$testClass->isAbstract()) { |
|
283 | + $this->addTest(new self($testClass)); |
|
284 | + } |
|
285 | + } else { |
|
286 | + throw new Exception; |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Wraps both <code>addTest()</code> and <code>addTestSuite</code> |
|
292 | + * as well as the separate import statements for the user's convenience. |
|
293 | + * |
|
294 | + * If the named file cannot be read or there are no new tests that can be |
|
295 | + * added, a <code>PHPUnit\Framework\WarningTestCase</code> will be created instead, |
|
296 | + * leaving the current test run untouched. |
|
297 | + * |
|
298 | + * @param string $filename |
|
299 | + * |
|
300 | + * @throws Exception |
|
301 | + */ |
|
302 | + public function addTestFile($filename) |
|
303 | + { |
|
304 | + if (!\is_string($filename)) { |
|
305 | + throw InvalidArgumentHelper::factory(1, 'string'); |
|
306 | + } |
|
307 | + |
|
308 | + if (\file_exists($filename) && \substr($filename, -5) == '.phpt') { |
|
309 | + $this->addTest( |
|
310 | + new PhptTestCase($filename) |
|
311 | + ); |
|
312 | + |
|
313 | + return; |
|
314 | + } |
|
315 | + |
|
316 | + // The given file may contain further stub classes in addition to the |
|
317 | + // test class itself. Figure out the actual test class. |
|
318 | + $classes = \get_declared_classes(); |
|
319 | + $filename = Fileloader::checkAndLoad($filename); |
|
320 | + $newClasses = \array_diff(\get_declared_classes(), $classes); |
|
321 | + |
|
322 | + // The diff is empty in case a parent class (with test methods) is added |
|
323 | + // AFTER a child class that inherited from it. To account for that case, |
|
324 | + // accumulate all discovered classes, so the parent class may be found in |
|
325 | + // a later invocation. |
|
326 | + if (!empty($newClasses)) { |
|
327 | + // On the assumption that test classes are defined first in files, |
|
328 | + // process discovered classes in approximate LIFO order, so as to |
|
329 | + // avoid unnecessary reflection. |
|
330 | + $this->foundClasses = \array_merge($newClasses, $this->foundClasses); |
|
331 | + } |
|
332 | + |
|
333 | + // The test class's name must match the filename, either in full, or as |
|
334 | + // a PEAR/PSR-0 prefixed shortname ('NameSpace_ShortName'), or as a |
|
335 | + // PSR-1 local shortname ('NameSpace\ShortName'). The comparison must be |
|
336 | + // anchored to prevent false-positive matches (e.g., 'OtherShortName'). |
|
337 | + $shortname = \basename($filename, '.php'); |
|
338 | + $shortnameRegEx = '/(?:^|_|\\\\)' . \preg_quote($shortname, '/') . '$/'; |
|
339 | + |
|
340 | + foreach ($this->foundClasses as $i => $className) { |
|
341 | + if (\preg_match($shortnameRegEx, $className)) { |
|
342 | + $class = new ReflectionClass($className); |
|
343 | + |
|
344 | + if ($class->getFileName() == $filename) { |
|
345 | + $newClasses = [$className]; |
|
346 | + unset($this->foundClasses[$i]); |
|
347 | + |
|
348 | + break; |
|
349 | + } |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + foreach ($newClasses as $className) { |
|
354 | + $class = new ReflectionClass($className); |
|
355 | + |
|
356 | + if (!$class->isAbstract()) { |
|
357 | + if ($class->hasMethod(BaseTestRunner::SUITE_METHODNAME)) { |
|
358 | + $method = $class->getMethod( |
|
359 | + BaseTestRunner::SUITE_METHODNAME |
|
360 | + ); |
|
361 | + |
|
362 | + if ($method->isStatic()) { |
|
363 | + $this->addTest($method->invoke(null, $className)); |
|
364 | + } |
|
365 | + } elseif ($class->implementsInterface(Test::class)) { |
|
366 | + $this->addTestSuite($class); |
|
367 | + } |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + $this->numTests = -1; |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Wrapper for addTestFile() that adds multiple test files. |
|
376 | + * |
|
377 | + * @param array|Iterator $filenames |
|
378 | + * |
|
379 | + * @throws Exception |
|
380 | + */ |
|
381 | + public function addTestFiles($filenames) |
|
382 | + { |
|
383 | + if (!(\is_array($filenames) || |
|
384 | + (\is_object($filenames) && $filenames instanceof Iterator))) { |
|
385 | + throw InvalidArgumentHelper::factory( |
|
386 | + 1, |
|
387 | + 'array or iterator' |
|
388 | + ); |
|
389 | + } |
|
390 | + |
|
391 | + foreach ($filenames as $filename) { |
|
392 | + $this->addTestFile((string) $filename); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Counts the number of test cases that will be run by this test. |
|
398 | + * |
|
399 | + * @param bool $preferCache Indicates if cache is preferred. |
|
400 | + * |
|
401 | + * @return int |
|
402 | + */ |
|
403 | + public function count($preferCache = false) |
|
404 | + { |
|
405 | + if ($preferCache && $this->cachedNumTests !== null) { |
|
406 | + return $this->cachedNumTests; |
|
407 | + } |
|
408 | + |
|
409 | + $numTests = 0; |
|
410 | + |
|
411 | + foreach ($this as $test) { |
|
412 | + $numTests += \count($test); |
|
413 | + } |
|
414 | + |
|
415 | + $this->cachedNumTests = $numTests; |
|
416 | + |
|
417 | + return $numTests; |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * @param ReflectionClass $theClass |
|
422 | + * @param string $name |
|
423 | + * |
|
424 | + * @return Test |
|
425 | + * |
|
426 | + * @throws Exception |
|
427 | + */ |
|
428 | + public static function createTest(ReflectionClass $theClass, $name) |
|
429 | + { |
|
430 | + $className = $theClass->getName(); |
|
431 | + |
|
432 | + if (!$theClass->isInstantiable()) { |
|
433 | + return self::warning( |
|
434 | + \sprintf('Cannot instantiate class "%s".', $className) |
|
435 | + ); |
|
436 | + } |
|
437 | + |
|
438 | + $backupSettings = \PHPUnit\Util\Test::getBackupSettings( |
|
439 | + $className, |
|
440 | + $name |
|
441 | + ); |
|
442 | + |
|
443 | + $preserveGlobalState = \PHPUnit\Util\Test::getPreserveGlobalStateSettings( |
|
444 | + $className, |
|
445 | + $name |
|
446 | + ); |
|
447 | + |
|
448 | + $runTestInSeparateProcess = \PHPUnit\Util\Test::getProcessIsolationSettings( |
|
449 | + $className, |
|
450 | + $name |
|
451 | + ); |
|
452 | + |
|
453 | + $runClassInSeparateProcess = \PHPUnit\Util\Test::getClassProcessIsolationSettings( |
|
454 | + $className, |
|
455 | + $name |
|
456 | + ); |
|
457 | + |
|
458 | + $constructor = $theClass->getConstructor(); |
|
459 | + |
|
460 | + if ($constructor !== null) { |
|
461 | + $parameters = $constructor->getParameters(); |
|
462 | + |
|
463 | + // TestCase() or TestCase($name) |
|
464 | + if (\count($parameters) < 2) { |
|
465 | + $test = new $className; |
|
466 | + } // TestCase($name, $data) |
|
467 | + else { |
|
468 | + try { |
|
469 | + $data = \PHPUnit\Util\Test::getProvidedData( |
|
470 | + $className, |
|
471 | + $name |
|
472 | + ); |
|
473 | + } catch (IncompleteTestError $e) { |
|
474 | + $message = \sprintf( |
|
475 | + 'Test for %s::%s marked incomplete by data provider', |
|
476 | + $className, |
|
477 | + $name |
|
478 | + ); |
|
479 | + |
|
480 | + $_message = $e->getMessage(); |
|
481 | + |
|
482 | + if (!empty($_message)) { |
|
483 | + $message .= "\n" . $_message; |
|
484 | + } |
|
485 | + |
|
486 | + $data = self::incompleteTest($className, $name, $message); |
|
487 | + } catch (SkippedTestError $e) { |
|
488 | + $message = \sprintf( |
|
489 | + 'Test for %s::%s skipped by data provider', |
|
490 | + $className, |
|
491 | + $name |
|
492 | + ); |
|
493 | + |
|
494 | + $_message = $e->getMessage(); |
|
495 | + |
|
496 | + if (!empty($_message)) { |
|
497 | + $message .= "\n" . $_message; |
|
498 | + } |
|
499 | + |
|
500 | + $data = self::skipTest($className, $name, $message); |
|
501 | + } catch (Throwable $_t) { |
|
502 | + $t = $_t; |
|
503 | + } catch (Exception $_t) { |
|
504 | + $t = $_t; |
|
505 | + } |
|
506 | + |
|
507 | + if (isset($t)) { |
|
508 | + $message = \sprintf( |
|
509 | + 'The data provider specified for %s::%s is invalid.', |
|
510 | + $className, |
|
511 | + $name |
|
512 | + ); |
|
513 | + |
|
514 | + $_message = $t->getMessage(); |
|
515 | + |
|
516 | + if (!empty($_message)) { |
|
517 | + $message .= "\n" . $_message; |
|
518 | + } |
|
519 | + |
|
520 | + $data = self::warning($message); |
|
521 | + } |
|
522 | + |
|
523 | + // Test method with @dataProvider. |
|
524 | + if (isset($data)) { |
|
525 | + $test = new DataProviderTestSuite( |
|
526 | + $className . '::' . $name |
|
527 | + ); |
|
528 | + |
|
529 | + if (empty($data)) { |
|
530 | + $data = self::warning( |
|
531 | + \sprintf( |
|
532 | + 'No tests found in suite "%s".', |
|
533 | + $test->getName() |
|
534 | + ) |
|
535 | + ); |
|
536 | + } |
|
537 | + |
|
538 | + $groups = \PHPUnit\Util\Test::getGroups($className, $name); |
|
539 | + |
|
540 | + if ($data instanceof WarningTestCase || |
|
541 | + $data instanceof SkippedTestCase || |
|
542 | + $data instanceof IncompleteTestCase) { |
|
543 | + $test->addTest($data, $groups); |
|
544 | + } else { |
|
545 | + foreach ($data as $_dataName => $_data) { |
|
546 | + $_test = new $className($name, $_data, $_dataName); |
|
547 | + |
|
548 | + if ($runTestInSeparateProcess) { |
|
549 | + $_test->setRunTestInSeparateProcess(true); |
|
550 | + |
|
551 | + if ($preserveGlobalState !== null) { |
|
552 | + $_test->setPreserveGlobalState($preserveGlobalState); |
|
553 | + } |
|
554 | + } |
|
555 | + |
|
556 | + if ($runClassInSeparateProcess) { |
|
557 | + $_test->setRunClassInSeparateProcess(true); |
|
558 | + |
|
559 | + if ($preserveGlobalState !== null) { |
|
560 | + $_test->setPreserveGlobalState($preserveGlobalState); |
|
561 | + } |
|
562 | + } |
|
563 | + |
|
564 | + if ($backupSettings['backupGlobals'] !== null) { |
|
565 | + $_test->setBackupGlobals( |
|
566 | + $backupSettings['backupGlobals'] |
|
567 | + ); |
|
568 | + } |
|
569 | + |
|
570 | + if ($backupSettings['backupStaticAttributes'] !== null) { |
|
571 | + $_test->setBackupStaticAttributes( |
|
572 | + $backupSettings['backupStaticAttributes'] |
|
573 | + ); |
|
574 | + } |
|
575 | + |
|
576 | + $test->addTest($_test, $groups); |
|
577 | + } |
|
578 | + } |
|
579 | + } else { |
|
580 | + $test = new $className; |
|
581 | + } |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + if (!isset($test)) { |
|
586 | + throw new Exception('No valid test provided.'); |
|
587 | + } |
|
588 | + |
|
589 | + if ($test instanceof TestCase) { |
|
590 | + $test->setName($name); |
|
591 | + |
|
592 | + if ($runTestInSeparateProcess) { |
|
593 | + $test->setRunTestInSeparateProcess(true); |
|
594 | + |
|
595 | + if ($preserveGlobalState !== null) { |
|
596 | + $test->setPreserveGlobalState($preserveGlobalState); |
|
597 | + } |
|
598 | + } |
|
599 | + |
|
600 | + if ($backupSettings['backupGlobals'] !== null) { |
|
601 | + $test->setBackupGlobals($backupSettings['backupGlobals']); |
|
602 | + } |
|
603 | + |
|
604 | + if ($backupSettings['backupStaticAttributes'] !== null) { |
|
605 | + $test->setBackupStaticAttributes( |
|
606 | + $backupSettings['backupStaticAttributes'] |
|
607 | + ); |
|
608 | + } |
|
609 | + } |
|
610 | + |
|
611 | + return $test; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Creates a default TestResult object. |
|
616 | + * |
|
617 | + * @return TestResult |
|
618 | + */ |
|
619 | + protected function createResult() |
|
620 | + { |
|
621 | + return new TestResult; |
|
622 | + } |
|
623 | + |
|
624 | + /** |
|
625 | + * Returns the name of the suite. |
|
626 | + * |
|
627 | + * @return string |
|
628 | + */ |
|
629 | + public function getName() |
|
630 | + { |
|
631 | + return $this->name; |
|
632 | + } |
|
633 | + |
|
634 | + /** |
|
635 | + * Returns the test groups of the suite. |
|
636 | + * |
|
637 | + * @return array |
|
638 | + */ |
|
639 | + public function getGroups() |
|
640 | + { |
|
641 | + return \array_keys($this->groups); |
|
642 | + } |
|
643 | + |
|
644 | + public function getGroupDetails() |
|
645 | + { |
|
646 | + return $this->groups; |
|
647 | + } |
|
648 | + |
|
649 | + /** |
|
650 | + * Set tests groups of the test case |
|
651 | + * |
|
652 | + * @param array $groups |
|
653 | + */ |
|
654 | + public function setGroupDetails(array $groups) |
|
655 | + { |
|
656 | + $this->groups = $groups; |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * Runs the tests and collects their result in a TestResult. |
|
661 | + * |
|
662 | + * @param TestResult $result |
|
663 | + * |
|
664 | + * @return TestResult |
|
665 | + */ |
|
666 | + public function run(TestResult $result = null) |
|
667 | + { |
|
668 | + if ($result === null) { |
|
669 | + $result = $this->createResult(); |
|
670 | + } |
|
671 | + |
|
672 | + if (\count($this) == 0) { |
|
673 | + return $result; |
|
674 | + } |
|
675 | + |
|
676 | + $hookMethods = \PHPUnit\Util\Test::getHookMethods($this->name); |
|
677 | + |
|
678 | + $result->startTestSuite($this); |
|
679 | + |
|
680 | + try { |
|
681 | + $this->setUp(); |
|
682 | + |
|
683 | + foreach ($hookMethods['beforeClass'] as $beforeClassMethod) { |
|
684 | + if ($this->testCase === true && |
|
685 | + \class_exists($this->name, false) && |
|
686 | + \method_exists($this->name, $beforeClassMethod)) { |
|
687 | + if ($missingRequirements = \PHPUnit\Util\Test::getMissingRequirements($this->name, $beforeClassMethod)) { |
|
688 | + $this->markTestSuiteSkipped(\implode(PHP_EOL, $missingRequirements)); |
|
689 | + } |
|
690 | + |
|
691 | + \call_user_func([$this->name, $beforeClassMethod]); |
|
692 | + } |
|
693 | + } |
|
694 | + } catch (SkippedTestSuiteError $e) { |
|
695 | + $numTests = \count($this); |
|
696 | + |
|
697 | + for ($i = 0; $i < $numTests; $i++) { |
|
698 | + $result->startTest($this); |
|
699 | + $result->addFailure($this, $e, 0); |
|
700 | + $result->endTest($this, 0); |
|
701 | + } |
|
702 | + |
|
703 | + $this->tearDown(); |
|
704 | + $result->endTestSuite($this); |
|
705 | + |
|
706 | + return $result; |
|
707 | + } catch (Throwable $_t) { |
|
708 | + $t = $_t; |
|
709 | + } catch (Exception $_t) { |
|
710 | + $t = $_t; |
|
711 | + } |
|
712 | + |
|
713 | + if (isset($t)) { |
|
714 | + $numTests = \count($this); |
|
715 | + |
|
716 | + for ($i = 0; $i < $numTests; $i++) { |
|
717 | + if ($result->shouldStop()) { |
|
718 | + break; |
|
719 | + } |
|
720 | + |
|
721 | + $result->startTest($this); |
|
722 | + $result->addError($this, $t, 0); |
|
723 | + $result->endTest($this, 0); |
|
724 | + } |
|
725 | + |
|
726 | + $this->tearDown(); |
|
727 | + $result->endTestSuite($this); |
|
728 | + |
|
729 | + return $result; |
|
730 | + } |
|
731 | + |
|
732 | + foreach ($this as $test) { |
|
733 | + if ($result->shouldStop()) { |
|
734 | + break; |
|
735 | + } |
|
736 | + |
|
737 | + if ($test instanceof TestCase || $test instanceof self) { |
|
738 | + $test->setbeStrictAboutChangesToGlobalState($this->beStrictAboutChangesToGlobalState); |
|
739 | + $test->setBackupGlobals($this->backupGlobals); |
|
740 | + $test->setBackupStaticAttributes($this->backupStaticAttributes); |
|
741 | + $test->setRunTestInSeparateProcess($this->runTestInSeparateProcess); |
|
742 | + } |
|
743 | + |
|
744 | + $test->run($result); |
|
745 | + } |
|
746 | + |
|
747 | + foreach ($hookMethods['afterClass'] as $afterClassMethod) { |
|
748 | + if ($this->testCase === true && \class_exists($this->name, false) && \method_exists($this->name, $afterClassMethod)) { |
|
749 | + \call_user_func([$this->name, $afterClassMethod]); |
|
750 | + } |
|
751 | + } |
|
752 | + |
|
753 | + $this->tearDown(); |
|
754 | + |
|
755 | + $result->endTestSuite($this); |
|
756 | + |
|
757 | + return $result; |
|
758 | + } |
|
759 | + |
|
760 | + /** |
|
761 | + * @param bool $runTestInSeparateProcess |
|
762 | + * |
|
763 | + * @throws Exception |
|
764 | + */ |
|
765 | + public function setRunTestInSeparateProcess($runTestInSeparateProcess) |
|
766 | + { |
|
767 | + if (\is_bool($runTestInSeparateProcess)) { |
|
768 | + $this->runTestInSeparateProcess = $runTestInSeparateProcess; |
|
769 | + } else { |
|
770 | + throw InvalidArgumentHelper::factory(1, 'boolean'); |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + /** |
|
775 | + * Runs a test. |
|
776 | + * |
|
777 | + * @deprecated |
|
778 | + * |
|
779 | + * @param Test $test |
|
780 | + * @param TestResult $result |
|
781 | + */ |
|
782 | + public function runTest(Test $test, TestResult $result) |
|
783 | + { |
|
784 | + $test->run($result); |
|
785 | + } |
|
786 | + |
|
787 | + /** |
|
788 | + * Sets the name of the suite. |
|
789 | + * |
|
790 | + * @param string |
|
791 | + */ |
|
792 | + public function setName($name) |
|
793 | + { |
|
794 | + $this->name = $name; |
|
795 | + } |
|
796 | + |
|
797 | + /** |
|
798 | + * Returns the test at the given index. |
|
799 | + * |
|
800 | + * @param int|false |
|
801 | + * |
|
802 | + * @return Test|false |
|
803 | + */ |
|
804 | + public function testAt($index) |
|
805 | + { |
|
806 | + if (isset($this->tests[$index])) { |
|
807 | + return $this->tests[$index]; |
|
808 | + } |
|
809 | + |
|
810 | + return false; |
|
811 | + } |
|
812 | + |
|
813 | + /** |
|
814 | + * Returns the tests as an enumeration. |
|
815 | + * |
|
816 | + * @return array |
|
817 | + */ |
|
818 | + public function tests() |
|
819 | + { |
|
820 | + return $this->tests; |
|
821 | + } |
|
822 | + |
|
823 | + /** |
|
824 | + * Set tests of the test suite |
|
825 | + * |
|
826 | + * @param array $tests |
|
827 | + */ |
|
828 | + public function setTests(array $tests) |
|
829 | + { |
|
830 | + $this->tests = $tests; |
|
831 | + } |
|
832 | + |
|
833 | + /** |
|
834 | + * Mark the test suite as skipped. |
|
835 | + * |
|
836 | + * @param string $message |
|
837 | + * |
|
838 | + * @throws SkippedTestSuiteError |
|
839 | + */ |
|
840 | + public function markTestSuiteSkipped($message = '') |
|
841 | + { |
|
842 | + throw new SkippedTestSuiteError($message); |
|
843 | + } |
|
844 | + |
|
845 | + /** |
|
846 | + * @param ReflectionClass $class |
|
847 | + * @param ReflectionMethod $method |
|
848 | + */ |
|
849 | + protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method) |
|
850 | + { |
|
851 | + if (!$this->isTestMethod($method)) { |
|
852 | + return; |
|
853 | + } |
|
854 | + |
|
855 | + $name = $method->getName(); |
|
856 | + |
|
857 | + if (!$method->isPublic()) { |
|
858 | + $this->addTest( |
|
859 | + self::warning( |
|
860 | + \sprintf( |
|
861 | + 'Test method "%s" in test class "%s" is not public.', |
|
862 | + $name, |
|
863 | + $class->getName() |
|
864 | + ) |
|
865 | + ) |
|
866 | + ); |
|
867 | + |
|
868 | + return; |
|
869 | + } |
|
870 | + |
|
871 | + $test = self::createTest($class, $name); |
|
872 | + |
|
873 | + if ($test instanceof TestCase || $test instanceof DataProviderTestSuite) { |
|
874 | + $test->setDependencies( |
|
875 | + \PHPUnit\Util\Test::getDependencies($class->getName(), $name) |
|
876 | + ); |
|
877 | + } |
|
878 | + |
|
879 | + $this->addTest( |
|
880 | + $test, |
|
881 | + \PHPUnit\Util\Test::getGroups($class->getName(), $name) |
|
882 | + ); |
|
883 | + } |
|
884 | + |
|
885 | + /** |
|
886 | + * @param ReflectionMethod $method |
|
887 | + * |
|
888 | + * @return bool |
|
889 | + */ |
|
890 | + public static function isTestMethod(ReflectionMethod $method) |
|
891 | + { |
|
892 | + if (\strpos($method->name, 'test') === 0) { |
|
893 | + return true; |
|
894 | + } |
|
895 | + |
|
896 | + // @scenario on TestCase::testMethod() |
|
897 | + // @test on TestCase::testMethod() |
|
898 | + $docComment = $method->getDocComment(); |
|
899 | + |
|
900 | + return \strpos($docComment, '@test') !== false || |
|
901 | + \strpos($docComment, '@scenario') !== false; |
|
902 | + } |
|
903 | + |
|
904 | + /** |
|
905 | + * @param string $message |
|
906 | + * |
|
907 | + * @return WarningTestCase |
|
908 | + */ |
|
909 | + protected static function warning($message) |
|
910 | + { |
|
911 | + return new WarningTestCase($message); |
|
912 | + } |
|
913 | + |
|
914 | + /** |
|
915 | + * @param string $class |
|
916 | + * @param string $methodName |
|
917 | + * @param string $message |
|
918 | + * |
|
919 | + * @return SkippedTestCase |
|
920 | + */ |
|
921 | + protected static function skipTest($class, $methodName, $message) |
|
922 | + { |
|
923 | + return new SkippedTestCase($class, $methodName, $message); |
|
924 | + } |
|
925 | + |
|
926 | + /** |
|
927 | + * @param string $class |
|
928 | + * @param string $methodName |
|
929 | + * @param string $message |
|
930 | + * |
|
931 | + * @return IncompleteTestCase |
|
932 | + */ |
|
933 | + protected static function incompleteTest($class, $methodName, $message) |
|
934 | + { |
|
935 | + return new IncompleteTestCase($class, $methodName, $message); |
|
936 | + } |
|
937 | + |
|
938 | + /** |
|
939 | + * @param bool $beStrictAboutChangesToGlobalState |
|
940 | + */ |
|
941 | + public function setbeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlobalState) |
|
942 | + { |
|
943 | + if (null === $this->beStrictAboutChangesToGlobalState && \is_bool($beStrictAboutChangesToGlobalState)) { |
|
944 | + $this->beStrictAboutChangesToGlobalState = $beStrictAboutChangesToGlobalState; |
|
945 | + } |
|
946 | + } |
|
947 | + |
|
948 | + /** |
|
949 | + * @param bool $backupGlobals |
|
950 | + */ |
|
951 | + public function setBackupGlobals($backupGlobals) |
|
952 | + { |
|
953 | + if (null === $this->backupGlobals && \is_bool($backupGlobals)) { |
|
954 | + $this->backupGlobals = $backupGlobals; |
|
955 | + } |
|
956 | + } |
|
957 | + |
|
958 | + /** |
|
959 | + * @param bool $backupStaticAttributes |
|
960 | + */ |
|
961 | + public function setBackupStaticAttributes($backupStaticAttributes) |
|
962 | + { |
|
963 | + if (null === $this->backupStaticAttributes && \is_bool($backupStaticAttributes)) { |
|
964 | + $this->backupStaticAttributes = $backupStaticAttributes; |
|
965 | + } |
|
966 | + } |
|
967 | + |
|
968 | + /** |
|
969 | + * Returns an iterator for this test suite. |
|
970 | + * |
|
971 | + * @return TestSuiteIterator |
|
972 | + */ |
|
973 | + public function getIterator() |
|
974 | + { |
|
975 | + $iterator = new TestSuiteIterator($this); |
|
976 | + |
|
977 | + if ($this->iteratorFilter !== null) { |
|
978 | + $iterator = $this->iteratorFilter->factory($iterator, $this); |
|
979 | + } |
|
980 | + |
|
981 | + return $iterator; |
|
982 | + } |
|
983 | + |
|
984 | + public function injectFilter(Factory $filter) |
|
985 | + { |
|
986 | + $this->iteratorFilter = $filter; |
|
987 | + foreach ($this as $test) { |
|
988 | + if ($test instanceof self) { |
|
989 | + $test->injectFilter($filter); |
|
990 | + } |
|
991 | + } |
|
992 | + } |
|
993 | + |
|
994 | + /** |
|
995 | + * Template Method that is called before the tests |
|
996 | + * of this test suite are run. |
|
997 | + */ |
|
998 | + protected function setUp() |
|
999 | + { |
|
1000 | + } |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * Template Method that is called after the tests |
|
1004 | + * of this test suite have finished running. |
|
1005 | + */ |
|
1006 | + protected function tearDown() |
|
1007 | + { |
|
1008 | + } |
|
1009 | 1009 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | if (!$theClass->isSubclassOf(TestCase::class)) { |
152 | 152 | throw new Exception( |
153 | - 'Class "' . $theClass->name . '" does not extend PHPUnit\Framework\TestCase.' |
|
153 | + 'Class "'.$theClass->name.'" does not extend PHPUnit\Framework\TestCase.' |
|
154 | 154 | ); |
155 | 155 | } |
156 | 156 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | // PSR-1 local shortname ('NameSpace\ShortName'). The comparison must be |
336 | 336 | // anchored to prevent false-positive matches (e.g., 'OtherShortName'). |
337 | 337 | $shortname = \basename($filename, '.php'); |
338 | - $shortnameRegEx = '/(?:^|_|\\\\)' . \preg_quote($shortname, '/') . '$/'; |
|
338 | + $shortnameRegEx = '/(?:^|_|\\\\)'.\preg_quote($shortname, '/').'$/'; |
|
339 | 339 | |
340 | 340 | foreach ($this->foundClasses as $i => $className) { |
341 | 341 | if (\preg_match($shortnameRegEx, $className)) { |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $_message = $e->getMessage(); |
481 | 481 | |
482 | 482 | if (!empty($_message)) { |
483 | - $message .= "\n" . $_message; |
|
483 | + $message .= "\n".$_message; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | $data = self::incompleteTest($className, $name, $message); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $_message = $e->getMessage(); |
495 | 495 | |
496 | 496 | if (!empty($_message)) { |
497 | - $message .= "\n" . $_message; |
|
497 | + $message .= "\n".$_message; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | $data = self::skipTest($className, $name, $message); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | $_message = $t->getMessage(); |
515 | 515 | |
516 | 516 | if (!empty($_message)) { |
517 | - $message .= "\n" . $_message; |
|
517 | + $message .= "\n".$_message; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | $data = self::warning($message); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // Test method with @dataProvider. |
524 | 524 | if (isset($data)) { |
525 | 525 | $test = new DataProviderTestSuite( |
526 | - $className . '::' . $name |
|
526 | + $className.'::'.$name |
|
527 | 527 | ); |
528 | 528 | |
529 | 529 | if (empty($data)) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function any() |
57 | 57 | { |
58 | - return TestCase::any(); |
|
58 | + return TestCase::any(); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function anything() |
67 | 67 | { |
68 | - return Assert::anything(); |
|
68 | + return Assert::anything(); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function arrayHasKey($key) |
79 | 79 | { |
80 | - return Assert::arrayHasKey(...\func_get_args()); |
|
80 | + return Assert::arrayHasKey(...\func_get_args()); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | function assertArrayHasKey($key, $array, $message = '') |
91 | 91 | { |
92 | - return Assert::assertArrayHasKey(...\func_get_args()); |
|
92 | + return Assert::assertArrayHasKey(...\func_get_args()); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function assertArraySubset($subset, $array, $strict = false, $message = '') |
104 | 104 | { |
105 | - return Assert::assertArraySubset(...\func_get_args()); |
|
105 | + return Assert::assertArraySubset(...\func_get_args()); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | function assertArrayNotHasKey($key, $array, $message = '') |
116 | 116 | { |
117 | - return Assert::assertArrayNotHasKey(...\func_get_args()); |
|
117 | + return Assert::assertArrayNotHasKey(...\func_get_args()); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
133 | 133 | { |
134 | - return Assert::assertAttributeContains(...\func_get_args()); |
|
134 | + return Assert::assertAttributeContains(...\func_get_args()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
148 | 148 | { |
149 | - return Assert::assertAttributeContainsOnly(...\func_get_args()); |
|
149 | + return Assert::assertAttributeContainsOnly(...\func_get_args()); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | function assertAttributeCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
162 | 162 | { |
163 | - return Assert::assertAttributeCount(...\func_get_args()); |
|
163 | + return Assert::assertAttributeCount(...\func_get_args()); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function assertAttributeEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
175 | 175 | { |
176 | - return Assert::assertAttributeEmpty(...\func_get_args()); |
|
176 | + return Assert::assertAttributeEmpty(...\func_get_args()); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | function assertAttributeEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
192 | 192 | { |
193 | - return Assert::assertAttributeEquals(...\func_get_args()); |
|
193 | + return Assert::assertAttributeEquals(...\func_get_args()); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | function assertAttributeGreaterThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
205 | 205 | { |
206 | - return Assert::assertAttributeGreaterThan(...\func_get_args()); |
|
206 | + return Assert::assertAttributeGreaterThan(...\func_get_args()); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | function assertAttributeGreaterThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
218 | 218 | { |
219 | - return Assert::assertAttributeGreaterThanOrEqual(...\func_get_args()); |
|
219 | + return Assert::assertAttributeGreaterThanOrEqual(...\func_get_args()); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function assertAttributeInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
231 | 231 | { |
232 | - return Assert::assertAttributeInstanceOf(...\func_get_args()); |
|
232 | + return Assert::assertAttributeInstanceOf(...\func_get_args()); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | function assertAttributeInternalType($expected, $attributeName, $classOrObject, $message = '') |
244 | 244 | { |
245 | - return Assert::assertAttributeInternalType(...\func_get_args()); |
|
245 | + return Assert::assertAttributeInternalType(...\func_get_args()); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | function assertAttributeLessThan($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
257 | 257 | { |
258 | - return Assert::assertAttributeLessThan(...\func_get_args()); |
|
258 | + return Assert::assertAttributeLessThan(...\func_get_args()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function assertAttributeLessThanOrEqual($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
270 | 270 | { |
271 | - return Assert::assertAttributeLessThanOrEqual(...\func_get_args()); |
|
271 | + return Assert::assertAttributeLessThanOrEqual(...\func_get_args()); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
287 | 287 | { |
288 | - return Assert::assertAttributeNotContains(...\func_get_args()); |
|
288 | + return Assert::assertAttributeNotContains(...\func_get_args()); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '') |
303 | 303 | { |
304 | - return Assert::assertAttributeNotContainsOnly(...\func_get_args()); |
|
304 | + return Assert::assertAttributeNotContainsOnly(...\func_get_args()); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function assertAttributeNotCount($expectedCount, $haystackAttributeName, $haystackClassOrObject, $message = '') |
317 | 317 | { |
318 | - return Assert::assertAttributeNotCount(...\func_get_args()); |
|
318 | + return Assert::assertAttributeNotCount(...\func_get_args()); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function assertAttributeNotEmpty($haystackAttributeName, $haystackClassOrObject, $message = '') |
330 | 330 | { |
331 | - return Assert::assertAttributeNotEmpty(...\func_get_args()); |
|
331 | + return Assert::assertAttributeNotEmpty(...\func_get_args()); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | */ |
346 | 346 | function assertAttributeNotEquals($expected, $actualAttributeName, $actualClassOrObject, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
347 | 347 | { |
348 | - return Assert::assertAttributeNotEquals(...\func_get_args()); |
|
348 | + return Assert::assertAttributeNotEquals(...\func_get_args()); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | function assertAttributeNotInstanceOf($expected, $attributeName, $classOrObject, $message = '') |
360 | 360 | { |
361 | - return Assert::assertAttributeNotInstanceOf(...\func_get_args()); |
|
361 | + return Assert::assertAttributeNotInstanceOf(...\func_get_args()); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | function assertAttributeNotInternalType($expected, $attributeName, $classOrObject, $message = '') |
373 | 373 | { |
374 | - return Assert::assertAttributeNotInternalType(...\func_get_args()); |
|
374 | + return Assert::assertAttributeNotInternalType(...\func_get_args()); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function assertAttributeNotSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
387 | 387 | { |
388 | - return Assert::assertAttributeNotSame(...\func_get_args()); |
|
388 | + return Assert::assertAttributeNotSame(...\func_get_args()); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | function assertAttributeSame($expected, $actualAttributeName, $actualClassOrObject, $message = '') |
401 | 401 | { |
402 | - return Assert::assertAttributeSame(...\func_get_args()); |
|
402 | + return Assert::assertAttributeSame(...\func_get_args()); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | */ |
412 | 412 | function assertClassHasAttribute($attributeName, $className, $message = '') |
413 | 413 | { |
414 | - return Assert::assertClassHasAttribute(...\func_get_args()); |
|
414 | + return Assert::assertClassHasAttribute(...\func_get_args()); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | function assertClassHasStaticAttribute($attributeName, $className, $message = '') |
425 | 425 | { |
426 | - return Assert::assertClassHasStaticAttribute(...\func_get_args()); |
|
426 | + return Assert::assertClassHasStaticAttribute(...\func_get_args()); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | function assertClassNotHasAttribute($attributeName, $className, $message = '') |
437 | 437 | { |
438 | - return Assert::assertClassNotHasAttribute(...\func_get_args()); |
|
438 | + return Assert::assertClassNotHasAttribute(...\func_get_args()); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | function assertClassNotHasStaticAttribute($attributeName, $className, $message = '') |
449 | 449 | { |
450 | - return Assert::assertClassNotHasStaticAttribute(...\func_get_args()); |
|
450 | + return Assert::assertClassNotHasStaticAttribute(...\func_get_args()); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | */ |
463 | 463 | function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
464 | 464 | { |
465 | - return Assert::assertContains(...\func_get_args()); |
|
465 | + return Assert::assertContains(...\func_get_args()); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | */ |
476 | 476 | function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
477 | 477 | { |
478 | - return Assert::assertContainsOnly(...\func_get_args()); |
|
478 | + return Assert::assertContainsOnly(...\func_get_args()); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | */ |
488 | 488 | function assertContainsOnlyInstancesOf($classname, $haystack, $message = '') |
489 | 489 | { |
490 | - return Assert::assertContainsOnlyInstancesOf(...\func_get_args()); |
|
490 | + return Assert::assertContainsOnlyInstancesOf(...\func_get_args()); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | /** |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | */ |
500 | 500 | function assertCount($expectedCount, $haystack, $message = '') |
501 | 501 | { |
502 | - return Assert::assertCount(...\func_get_args()); |
|
502 | + return Assert::assertCount(...\func_get_args()); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | */ |
513 | 513 | function assertEmpty($actual, $message = '') |
514 | 514 | { |
515 | - return Assert::assertEmpty(...\func_get_args()); |
|
515 | + return Assert::assertEmpty(...\func_get_args()); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | */ |
526 | 526 | function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, $checkAttributes = false, $message = '') |
527 | 527 | { |
528 | - return Assert::assertEqualXMLStructure(...\func_get_args()); |
|
528 | + return Assert::assertEqualXMLStructure(...\func_get_args()); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | function assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
543 | 543 | { |
544 | - return Assert::assertEquals(...\func_get_args()); |
|
544 | + return Assert::assertEquals(...\func_get_args()); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | function assertNotTrue($condition, $message = '') |
556 | 556 | { |
557 | - return Assert::assertNotTrue(...\func_get_args()); |
|
557 | + return Assert::assertNotTrue(...\func_get_args()); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | function assertFalse($condition, $message = '') |
569 | 569 | { |
570 | - return Assert::assertFalse(...\func_get_args()); |
|
570 | + return Assert::assertFalse(...\func_get_args()); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | */ |
583 | 583 | function assertFileEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
584 | 584 | { |
585 | - return Assert::assertFileEquals(...\func_get_args()); |
|
585 | + return Assert::assertFileEquals(...\func_get_args()); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | */ |
594 | 594 | function assertFileExists($filename, $message = '') |
595 | 595 | { |
596 | - return Assert::assertFileExists(...\func_get_args()); |
|
596 | + return Assert::assertFileExists(...\func_get_args()); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | function assertFileNotEquals($expected, $actual, $message = '', $canonicalize = false, $ignoreCase = false) |
610 | 610 | { |
611 | - return Assert::assertFileNotEquals(...\func_get_args()); |
|
611 | + return Assert::assertFileNotEquals(...\func_get_args()); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | */ |
620 | 620 | function assertFileNotExists($filename, $message = '') |
621 | 621 | { |
622 | - return Assert::assertFileNotExists(...\func_get_args()); |
|
622 | + return Assert::assertFileNotExists(...\func_get_args()); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | */ |
632 | 632 | function assertGreaterThan($expected, $actual, $message = '') |
633 | 633 | { |
634 | - return Assert::assertGreaterThan(...\func_get_args()); |
|
634 | + return Assert::assertGreaterThan(...\func_get_args()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | */ |
644 | 644 | function assertGreaterThanOrEqual($expected, $actual, $message = '') |
645 | 645 | { |
646 | - return Assert::assertGreaterThanOrEqual(...\func_get_args()); |
|
646 | + return Assert::assertGreaterThanOrEqual(...\func_get_args()); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | */ |
656 | 656 | function assertInstanceOf($expected, $actual, $message = '') |
657 | 657 | { |
658 | - return Assert::assertInstanceOf(...\func_get_args()); |
|
658 | + return Assert::assertInstanceOf(...\func_get_args()); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | function assertInternalType($expected, $actual, $message = '') |
669 | 669 | { |
670 | - return Assert::assertInternalType(...\func_get_args()); |
|
670 | + return Assert::assertInternalType(...\func_get_args()); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | */ |
679 | 679 | function assertJson($actualJson, $message = '') |
680 | 680 | { |
681 | - return Assert::assertJson(...\func_get_args()); |
|
681 | + return Assert::assertJson(...\func_get_args()); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | */ |
691 | 691 | function assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = '') |
692 | 692 | { |
693 | - return Assert::assertJsonFileEqualsJsonFile(...\func_get_args()); |
|
693 | + return Assert::assertJsonFileEqualsJsonFile(...\func_get_args()); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | function assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = '') |
704 | 704 | { |
705 | - return Assert::assertJsonFileNotEqualsJsonFile(...\func_get_args()); |
|
705 | + return Assert::assertJsonFileNotEqualsJsonFile(...\func_get_args()); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | */ |
715 | 715 | function assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = '') |
716 | 716 | { |
717 | - return Assert::assertJsonStringEqualsJsonFile(...\func_get_args()); |
|
717 | + return Assert::assertJsonStringEqualsJsonFile(...\func_get_args()); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | */ |
727 | 727 | function assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = '') |
728 | 728 | { |
729 | - return Assert::assertJsonStringEqualsJsonString(...\func_get_args()); |
|
729 | + return Assert::assertJsonStringEqualsJsonString(...\func_get_args()); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | */ |
739 | 739 | function assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = '') |
740 | 740 | { |
741 | - return Assert::assertJsonStringNotEqualsJsonFile(...\func_get_args()); |
|
741 | + return Assert::assertJsonStringNotEqualsJsonFile(...\func_get_args()); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | */ |
751 | 751 | function assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = '') |
752 | 752 | { |
753 | - return Assert::assertJsonStringNotEqualsJsonString(...\func_get_args()); |
|
753 | + return Assert::assertJsonStringNotEqualsJsonString(...\func_get_args()); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | */ |
763 | 763 | function assertLessThan($expected, $actual, $message = '') |
764 | 764 | { |
765 | - return Assert::assertLessThan(...\func_get_args()); |
|
765 | + return Assert::assertLessThan(...\func_get_args()); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | */ |
775 | 775 | function assertLessThanOrEqual($expected, $actual, $message = '') |
776 | 776 | { |
777 | - return Assert::assertLessThanOrEqual(...\func_get_args()); |
|
777 | + return Assert::assertLessThanOrEqual(...\func_get_args()); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | */ |
786 | 786 | function assertFinite($actual, $message = '') |
787 | 787 | { |
788 | - return Assert::assertFinite(...\func_get_args()); |
|
788 | + return Assert::assertFinite(...\func_get_args()); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | /** |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | function assertInfinite($actual, $message = '') |
798 | 798 | { |
799 | - return Assert::assertInfinite(...\func_get_args()); |
|
799 | + return Assert::assertInfinite(...\func_get_args()); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | */ |
808 | 808 | function assertNan($actual, $message = '') |
809 | 809 | { |
810 | - return Assert::assertNan(...\func_get_args()); |
|
810 | + return Assert::assertNan(...\func_get_args()); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | */ |
823 | 823 | function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
824 | 824 | { |
825 | - return Assert::assertNotContains(...\func_get_args()); |
|
825 | + return Assert::assertNotContains(...\func_get_args()); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | */ |
836 | 836 | function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
837 | 837 | { |
838 | - return Assert::assertNotContainsOnly(...\func_get_args()); |
|
838 | + return Assert::assertNotContainsOnly(...\func_get_args()); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | */ |
848 | 848 | function assertNotCount($expectedCount, $haystack, $message = '') |
849 | 849 | { |
850 | - return Assert::assertNotCount(...\func_get_args()); |
|
850 | + return Assert::assertNotCount(...\func_get_args()); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | /** |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | */ |
861 | 861 | function assertNotEmpty($actual, $message = '') |
862 | 862 | { |
863 | - return Assert::assertNotEmpty(...\func_get_args()); |
|
863 | + return Assert::assertNotEmpty(...\func_get_args()); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | /** |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | */ |
877 | 877 | function assertNotEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
878 | 878 | { |
879 | - return Assert::assertNotEquals(...\func_get_args()); |
|
879 | + return Assert::assertNotEquals(...\func_get_args()); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | */ |
889 | 889 | function assertNotInstanceOf($expected, $actual, $message = '') |
890 | 890 | { |
891 | - return Assert::assertNotInstanceOf(...\func_get_args()); |
|
891 | + return Assert::assertNotInstanceOf(...\func_get_args()); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | */ |
901 | 901 | function assertNotInternalType($expected, $actual, $message = '') |
902 | 902 | { |
903 | - return Assert::assertNotInternalType(...\func_get_args()); |
|
903 | + return Assert::assertNotInternalType(...\func_get_args()); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | */ |
914 | 914 | function assertNotFalse($condition, $message = '') |
915 | 915 | { |
916 | - return Assert::assertNotFalse(...\func_get_args()); |
|
916 | + return Assert::assertNotFalse(...\func_get_args()); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | */ |
925 | 925 | function assertNotNull($actual, $message = '') |
926 | 926 | { |
927 | - return Assert::assertNotNull(...\func_get_args()); |
|
927 | + return Assert::assertNotNull(...\func_get_args()); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | */ |
937 | 937 | function assertNotRegExp($pattern, $string, $message = '') |
938 | 938 | { |
939 | - return Assert::assertNotRegExp(...\func_get_args()); |
|
939 | + return Assert::assertNotRegExp(...\func_get_args()); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | */ |
951 | 951 | function assertNotSame($expected, $actual, $message = '') |
952 | 952 | { |
953 | - return Assert::assertNotSame(...\func_get_args()); |
|
953 | + return Assert::assertNotSame(...\func_get_args()); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | */ |
964 | 964 | function assertNotSameSize($expected, $actual, $message = '') |
965 | 965 | { |
966 | - return Assert::assertNotSameSize(...\func_get_args()); |
|
966 | + return Assert::assertNotSameSize(...\func_get_args()); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | */ |
975 | 975 | function assertNull($actual, $message = '') |
976 | 976 | { |
977 | - return Assert::assertNull(...\func_get_args()); |
|
977 | + return Assert::assertNull(...\func_get_args()); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | /** |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | */ |
987 | 987 | function assertObjectHasAttribute($attributeName, $object, $message = '') |
988 | 988 | { |
989 | - return Assert::assertObjectHasAttribute(...\func_get_args()); |
|
989 | + return Assert::assertObjectHasAttribute(...\func_get_args()); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | /** |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | */ |
999 | 999 | function assertObjectNotHasAttribute($attributeName, $object, $message = '') |
1000 | 1000 | { |
1001 | - return Assert::assertObjectNotHasAttribute(...\func_get_args()); |
|
1001 | + return Assert::assertObjectNotHasAttribute(...\func_get_args()); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | */ |
1011 | 1011 | function assertRegExp($pattern, $string, $message = '') |
1012 | 1012 | { |
1013 | - return Assert::assertRegExp(...\func_get_args()); |
|
1013 | + return Assert::assertRegExp(...\func_get_args()); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | */ |
1025 | 1025 | function assertSame($expected, $actual, $message = '') |
1026 | 1026 | { |
1027 | - return Assert::assertSame(...\func_get_args()); |
|
1027 | + return Assert::assertSame(...\func_get_args()); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | */ |
1038 | 1038 | function assertSameSize($expected, $actual, $message = '') |
1039 | 1039 | { |
1040 | - return Assert::assertSameSize(...\func_get_args()); |
|
1040 | + return Assert::assertSameSize(...\func_get_args()); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | */ |
1050 | 1050 | function assertStringEndsNotWith($suffix, $string, $message = '') |
1051 | 1051 | { |
1052 | - return Assert::assertStringEndsNotWith(...\func_get_args()); |
|
1052 | + return Assert::assertStringEndsNotWith(...\func_get_args()); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | */ |
1062 | 1062 | function assertStringEndsWith($suffix, $string, $message = '') |
1063 | 1063 | { |
1064 | - return Assert::assertStringEndsWith(...\func_get_args()); |
|
1064 | + return Assert::assertStringEndsWith(...\func_get_args()); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | */ |
1077 | 1077 | function assertStringEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false) |
1078 | 1078 | { |
1079 | - return Assert::assertStringEqualsFile(...\func_get_args()); |
|
1079 | + return Assert::assertStringEqualsFile(...\func_get_args()); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | /** |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | function assertStringMatchesFormat($format, $string, $message = '') |
1090 | 1090 | { |
1091 | - return Assert::assertStringMatchesFormat(...\func_get_args()); |
|
1091 | + return Assert::assertStringMatchesFormat(...\func_get_args()); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | /** |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | */ |
1101 | 1101 | function assertStringMatchesFormatFile($formatFile, $string, $message = '') |
1102 | 1102 | { |
1103 | - return Assert::assertStringMatchesFormatFile(...\func_get_args()); |
|
1103 | + return Assert::assertStringMatchesFormatFile(...\func_get_args()); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | /** |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | function assertStringNotEqualsFile($expectedFile, $actualString, $message = '', $canonicalize = false, $ignoreCase = false) |
1117 | 1117 | { |
1118 | - return Assert::assertStringNotEqualsFile(...\func_get_args()); |
|
1118 | + return Assert::assertStringNotEqualsFile(...\func_get_args()); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | /** |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | function assertStringNotMatchesFormat($format, $string, $message = '') |
1129 | 1129 | { |
1130 | - return Assert::assertStringNotMatchesFormat(...\func_get_args()); |
|
1130 | + return Assert::assertStringNotMatchesFormat(...\func_get_args()); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | /** |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | */ |
1140 | 1140 | function assertStringNotMatchesFormatFile($formatFile, $string, $message = '') |
1141 | 1141 | { |
1142 | - return Assert::assertStringNotMatchesFormatFile(...\func_get_args()); |
|
1142 | + return Assert::assertStringNotMatchesFormatFile(...\func_get_args()); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | /** |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | */ |
1152 | 1152 | function assertStringStartsNotWith($prefix, $string, $message = '') |
1153 | 1153 | { |
1154 | - return Assert::assertStringStartsNotWith(...\func_get_args()); |
|
1154 | + return Assert::assertStringStartsNotWith(...\func_get_args()); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | function assertStringStartsWith($prefix, $string, $message = '') |
1165 | 1165 | { |
1166 | - return Assert::assertStringStartsWith(...\func_get_args()); |
|
1166 | + return Assert::assertStringStartsWith(...\func_get_args()); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | */ |
1176 | 1176 | function assertThat($value, Constraint $constraint, $message = '') |
1177 | 1177 | { |
1178 | - return Assert::assertThat(...\func_get_args()); |
|
1178 | + return Assert::assertThat(...\func_get_args()); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | /** |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | */ |
1189 | 1189 | function assertTrue($condition, $message = '') |
1190 | 1190 | { |
1191 | - return Assert::assertTrue(...\func_get_args()); |
|
1191 | + return Assert::assertTrue(...\func_get_args()); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | /** |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | function assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = '') |
1202 | 1202 | { |
1203 | - return Assert::assertXmlFileEqualsXmlFile(...\func_get_args()); |
|
1203 | + return Assert::assertXmlFileEqualsXmlFile(...\func_get_args()); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | /** |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | */ |
1213 | 1213 | function assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = '') |
1214 | 1214 | { |
1215 | - return Assert::assertXmlFileNotEqualsXmlFile(...\func_get_args()); |
|
1215 | + return Assert::assertXmlFileNotEqualsXmlFile(...\func_get_args()); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | */ |
1225 | 1225 | function assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = '') |
1226 | 1226 | { |
1227 | - return Assert::assertXmlStringEqualsXmlFile(...\func_get_args()); |
|
1227 | + return Assert::assertXmlStringEqualsXmlFile(...\func_get_args()); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | */ |
1237 | 1237 | function assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = '') |
1238 | 1238 | { |
1239 | - return Assert::assertXmlStringEqualsXmlString(...\func_get_args()); |
|
1239 | + return Assert::assertXmlStringEqualsXmlString(...\func_get_args()); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | /** |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | */ |
1249 | 1249 | function assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = '') |
1250 | 1250 | { |
1251 | - return Assert::assertXmlStringNotEqualsXmlFile(...\func_get_args()); |
|
1251 | + return Assert::assertXmlStringNotEqualsXmlFile(...\func_get_args()); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = '') |
1262 | 1262 | { |
1263 | - return Assert::assertXmlStringNotEqualsXmlString(...\func_get_args()); |
|
1263 | + return Assert::assertXmlStringNotEqualsXmlString(...\func_get_args()); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | /** |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | */ |
1274 | 1274 | function at($index) |
1275 | 1275 | { |
1276 | - return TestCase::at(...\func_get_args()); |
|
1276 | + return TestCase::at(...\func_get_args()); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | /** |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | */ |
1284 | 1284 | function atLeastOnce() |
1285 | 1285 | { |
1286 | - return TestCase::atLeastOnce(); |
|
1286 | + return TestCase::atLeastOnce(); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | /** |
@@ -1296,7 +1296,7 @@ discard block |
||
1296 | 1296 | */ |
1297 | 1297 | function attribute(Constraint $constraint, $attributeName) |
1298 | 1298 | { |
1299 | - return Assert::attribute(...\func_get_args()); |
|
1299 | + return Assert::attribute(...\func_get_args()); |
|
1300 | 1300 | } |
1301 | 1301 | |
1302 | 1302 | /** |
@@ -1315,7 +1315,7 @@ discard block |
||
1315 | 1315 | */ |
1316 | 1316 | function attributeEqualTo($attributeName, $value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
1317 | 1317 | { |
1318 | - return Assert::attributeEqualTo(...\func_get_args()); |
|
1318 | + return Assert::attributeEqualTo(...\func_get_args()); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | /** |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | */ |
1328 | 1328 | function callback($callback) |
1329 | 1329 | { |
1330 | - return Assert::callback(...\func_get_args()); |
|
1330 | + return Assert::callback(...\func_get_args()); |
|
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | /** |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | */ |
1340 | 1340 | function classHasAttribute($attributeName) |
1341 | 1341 | { |
1342 | - return Assert::classHasAttribute(...\func_get_args()); |
|
1342 | + return Assert::classHasAttribute(...\func_get_args()); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | 1345 | /** |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | */ |
1353 | 1353 | function classHasStaticAttribute($attributeName) |
1354 | 1354 | { |
1355 | - return Assert::classHasStaticAttribute(...\func_get_args()); |
|
1355 | + return Assert::classHasStaticAttribute(...\func_get_args()); |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | /** |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | */ |
1368 | 1368 | function contains($value, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
1369 | 1369 | { |
1370 | - return Assert::contains(...\func_get_args()); |
|
1370 | + return Assert::contains(...\func_get_args()); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | /** |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | */ |
1381 | 1381 | function containsOnly($type) |
1382 | 1382 | { |
1383 | - return Assert::containsOnly(...\func_get_args()); |
|
1383 | + return Assert::containsOnly(...\func_get_args()); |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | /** |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | */ |
1394 | 1394 | function containsOnlyInstancesOf($classname) |
1395 | 1395 | { |
1396 | - return Assert::containsOnlyInstancesOf(...\func_get_args()); |
|
1396 | + return Assert::containsOnlyInstancesOf(...\func_get_args()); |
|
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | */ |
1406 | 1406 | function countOf($count) |
1407 | 1407 | { |
1408 | - return Assert::countOf(...\func_get_args()); |
|
1408 | + return Assert::countOf(...\func_get_args()); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | /** |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | */ |
1416 | 1416 | function directoryExists() |
1417 | 1417 | { |
1418 | - return Assert::directoryExists(); |
|
1418 | + return Assert::directoryExists(); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | /** |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | */ |
1432 | 1432 | function equalTo($value, $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) |
1433 | 1433 | { |
1434 | - return Assert::equalTo(...\func_get_args()); |
|
1434 | + return Assert::equalTo(...\func_get_args()); |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | /** |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | */ |
1445 | 1445 | function exactly($count) |
1446 | 1446 | { |
1447 | - return TestCase::exactly(...\func_get_args()); |
|
1447 | + return TestCase::exactly(...\func_get_args()); |
|
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | /** |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | */ |
1455 | 1455 | function fileExists() |
1456 | 1456 | { |
1457 | - return Assert::fileExists(); |
|
1457 | + return Assert::fileExists(); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | /** |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | */ |
1467 | 1467 | function greaterThan($value) |
1468 | 1468 | { |
1469 | - return Assert::greaterThan(...\func_get_args()); |
|
1469 | + return Assert::greaterThan(...\func_get_args()); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | /** |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | */ |
1481 | 1481 | function greaterThanOrEqual($value) |
1482 | 1482 | { |
1483 | - return Assert::greaterThanOrEqual(...\func_get_args()); |
|
1483 | + return Assert::greaterThanOrEqual(...\func_get_args()); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | */ |
1493 | 1493 | function identicalTo($value) |
1494 | 1494 | { |
1495 | - return Assert::identicalTo(...\func_get_args()); |
|
1495 | + return Assert::identicalTo(...\func_get_args()); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | /** |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | */ |
1503 | 1503 | function isEmpty() |
1504 | 1504 | { |
1505 | - return Assert::isEmpty(); |
|
1505 | + return Assert::isEmpty(); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | /** |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | */ |
1513 | 1513 | function isFalse() |
1514 | 1514 | { |
1515 | - return Assert::isFalse(); |
|
1515 | + return Assert::isFalse(); |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | 1518 | /** |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | */ |
1523 | 1523 | function isInfinite() |
1524 | 1524 | { |
1525 | - return Assert::isInfinite(); |
|
1525 | + return Assert::isInfinite(); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | /** |
@@ -1534,7 +1534,7 @@ discard block |
||
1534 | 1534 | */ |
1535 | 1535 | function isInstanceOf($className) |
1536 | 1536 | { |
1537 | - return Assert::isInstanceOf(...\func_get_args()); |
|
1537 | + return Assert::isInstanceOf(...\func_get_args()); |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | /** |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | */ |
1545 | 1545 | function isJson() |
1546 | 1546 | { |
1547 | - return Assert::isJson(); |
|
1547 | + return Assert::isJson(); |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | /** |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | */ |
1555 | 1555 | function isNan() |
1556 | 1556 | { |
1557 | - return Assert::isNan(); |
|
1557 | + return Assert::isNan(); |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | /** |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | */ |
1565 | 1565 | function isNull() |
1566 | 1566 | { |
1567 | - return Assert::isNull(); |
|
1567 | + return Assert::isNull(); |
|
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | /** |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | */ |
1575 | 1575 | function isReadable() |
1576 | 1576 | { |
1577 | - return Assert::isReadable(); |
|
1577 | + return Assert::isReadable(); |
|
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | /** |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | function isTrue() |
1586 | 1586 | { |
1587 | - return Assert::isTrue(); |
|
1587 | + return Assert::isTrue(); |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | /** |
@@ -1596,7 +1596,7 @@ discard block |
||
1596 | 1596 | */ |
1597 | 1597 | function isType($type) |
1598 | 1598 | { |
1599 | - return Assert::isType(...\func_get_args()); |
|
1599 | + return Assert::isType(...\func_get_args()); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | /** |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | */ |
1607 | 1607 | function isWritable() |
1608 | 1608 | { |
1609 | - return Assert::isWritable(); |
|
1609 | + return Assert::isWritable(); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | /** |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | */ |
1619 | 1619 | function lessThan($value) |
1620 | 1620 | { |
1621 | - return Assert::lessThan(...\func_get_args()); |
|
1621 | + return Assert::lessThan(...\func_get_args()); |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | /** |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | */ |
1633 | 1633 | function lessThanOrEqual($value) |
1634 | 1634 | { |
1635 | - return Assert::lessThanOrEqual(...\func_get_args()); |
|
1635 | + return Assert::lessThanOrEqual(...\func_get_args()); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | /** |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | */ |
1643 | 1643 | function logicalAnd() |
1644 | 1644 | { |
1645 | - return Assert::logicalAnd(...\func_get_args()); |
|
1645 | + return Assert::logicalAnd(...\func_get_args()); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1654,7 +1654,7 @@ discard block |
||
1654 | 1654 | */ |
1655 | 1655 | function logicalNot(Constraint $constraint) |
1656 | 1656 | { |
1657 | - return Assert::logicalNot(...\func_get_args()); |
|
1657 | + return Assert::logicalNot(...\func_get_args()); |
|
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | /** |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | */ |
1665 | 1665 | function logicalOr() |
1666 | 1666 | { |
1667 | - return Assert::logicalOr(...\func_get_args()); |
|
1667 | + return Assert::logicalOr(...\func_get_args()); |
|
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | /** |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | */ |
1675 | 1675 | function logicalXor() |
1676 | 1676 | { |
1677 | - return Assert::logicalXor(...\func_get_args()); |
|
1677 | + return Assert::logicalXor(...\func_get_args()); |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | /** |
@@ -1686,7 +1686,7 @@ discard block |
||
1686 | 1686 | */ |
1687 | 1687 | function matches($string) |
1688 | 1688 | { |
1689 | - return Assert::matches(...\func_get_args()); |
|
1689 | + return Assert::matches(...\func_get_args()); |
|
1690 | 1690 | } |
1691 | 1691 | |
1692 | 1692 | /** |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | */ |
1699 | 1699 | function matchesRegularExpression($pattern) |
1700 | 1700 | { |
1701 | - return Assert::matchesRegularExpression(...\func_get_args()); |
|
1701 | + return Assert::matchesRegularExpression(...\func_get_args()); |
|
1702 | 1702 | } |
1703 | 1703 | |
1704 | 1704 | /** |
@@ -1708,7 +1708,7 @@ discard block |
||
1708 | 1708 | */ |
1709 | 1709 | function never() |
1710 | 1710 | { |
1711 | - return TestCase::never(); |
|
1711 | + return TestCase::never(); |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | /** |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | */ |
1721 | 1721 | function objectHasAttribute($attributeName) |
1722 | 1722 | { |
1723 | - return Assert::objectHasAttribute(...\func_get_args()); |
|
1723 | + return Assert::objectHasAttribute(...\func_get_args()); |
|
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | /** |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | */ |
1731 | 1731 | function onConsecutiveCalls() |
1732 | 1732 | { |
1733 | - return TestCase::onConsecutiveCalls(...\func_get_args()); |
|
1733 | + return TestCase::onConsecutiveCalls(...\func_get_args()); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | /** |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | */ |
1741 | 1741 | function once() |
1742 | 1742 | { |
1743 | - return TestCase::once(); |
|
1743 | + return TestCase::once(); |
|
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | /** |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | */ |
1751 | 1751 | function returnArgument($argumentIndex) |
1752 | 1752 | { |
1753 | - return TestCase::returnArgument(...\func_get_args()); |
|
1753 | + return TestCase::returnArgument(...\func_get_args()); |
|
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | /** |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | */ |
1761 | 1761 | function returnCallback($callback) |
1762 | 1762 | { |
1763 | - return TestCase::returnCallback(...\func_get_args()); |
|
1763 | + return TestCase::returnCallback(...\func_get_args()); |
|
1764 | 1764 | } |
1765 | 1765 | |
1766 | 1766 | /** |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | */ |
1773 | 1773 | function returnSelf() |
1774 | 1774 | { |
1775 | - return TestCase::returnSelf(); |
|
1775 | + return TestCase::returnSelf(); |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | /** |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | */ |
1783 | 1783 | function returnValue($value) |
1784 | 1784 | { |
1785 | - return TestCase::returnValue(...\func_get_args()); |
|
1785 | + return TestCase::returnValue(...\func_get_args()); |
|
1786 | 1786 | } |
1787 | 1787 | |
1788 | 1788 | /** |
@@ -1792,7 +1792,7 @@ discard block |
||
1792 | 1792 | */ |
1793 | 1793 | function returnValueMap(array $valueMap) |
1794 | 1794 | { |
1795 | - return TestCase::returnValueMap(...\func_get_args()); |
|
1795 | + return TestCase::returnValueMap(...\func_get_args()); |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | /** |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | */ |
1806 | 1806 | function stringContains($string, $case = true) |
1807 | 1807 | { |
1808 | - return Assert::stringContains(...\func_get_args()); |
|
1808 | + return Assert::stringContains(...\func_get_args()); |
|
1809 | 1809 | } |
1810 | 1810 | |
1811 | 1811 | /** |
@@ -1817,7 +1817,7 @@ discard block |
||
1817 | 1817 | */ |
1818 | 1818 | function stringEndsWith($suffix) |
1819 | 1819 | { |
1820 | - return Assert::stringEndsWith(...\func_get_args()); |
|
1820 | + return Assert::stringEndsWith(...\func_get_args()); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | /** |
@@ -1829,7 +1829,7 @@ discard block |
||
1829 | 1829 | */ |
1830 | 1830 | function stringStartsWith($prefix) |
1831 | 1831 | { |
1832 | - return Assert::stringStartsWith(...\func_get_args()); |
|
1832 | + return Assert::stringStartsWith(...\func_get_args()); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | 1835 | /** |
@@ -1839,5 +1839,5 @@ discard block |
||
1839 | 1839 | */ |
1840 | 1840 | function throwException(Exception $exception) |
1841 | 1841 | { |
1842 | - return TestCase::throwException(...\func_get_args()); |
|
1842 | + return TestCase::throwException(...\func_get_args()); |
|
1843 | 1843 | } |
@@ -21,127 +21,127 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class BaseTestRunner |
23 | 23 | { |
24 | - const STATUS_PASSED = 0; |
|
25 | - const STATUS_SKIPPED = 1; |
|
26 | - const STATUS_INCOMPLETE = 2; |
|
27 | - const STATUS_FAILURE = 3; |
|
28 | - const STATUS_ERROR = 4; |
|
29 | - const STATUS_RISKY = 5; |
|
30 | - const STATUS_WARNING = 6; |
|
31 | - const SUITE_METHODNAME = 'suite'; |
|
32 | - |
|
33 | - /** |
|
34 | - * Returns the loader to be used. |
|
35 | - * |
|
36 | - * @return TestSuiteLoader |
|
37 | - */ |
|
38 | - public function getLoader() |
|
39 | - { |
|
40 | - return new StandardTestSuiteLoader; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Returns the Test corresponding to the given suite. |
|
45 | - * This is a template method, subclasses override |
|
46 | - * the runFailed() and clearStatus() methods. |
|
47 | - * |
|
48 | - * @param string $suiteClassName |
|
49 | - * @param string $suiteClassFile |
|
50 | - * @param mixed $suffixes |
|
51 | - * |
|
52 | - * @return Test|null |
|
53 | - */ |
|
54 | - public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') |
|
55 | - { |
|
56 | - if (\is_dir($suiteClassName) && |
|
57 | - !\is_file($suiteClassName . '.php') && empty($suiteClassFile)) { |
|
58 | - $facade = new File_Iterator_Facade; |
|
59 | - $files = $facade->getFilesAsArray( |
|
60 | - $suiteClassName, |
|
61 | - $suffixes |
|
62 | - ); |
|
63 | - |
|
64 | - $suite = new TestSuite($suiteClassName); |
|
65 | - $suite->addTestFiles($files); |
|
66 | - |
|
67 | - return $suite; |
|
68 | - } |
|
69 | - |
|
70 | - try { |
|
71 | - $testClass = $this->loadSuiteClass( |
|
72 | - $suiteClassName, |
|
73 | - $suiteClassFile |
|
74 | - ); |
|
75 | - } catch (Exception $e) { |
|
76 | - $this->runFailed($e->getMessage()); |
|
77 | - |
|
78 | - return; |
|
79 | - } |
|
80 | - |
|
81 | - try { |
|
82 | - $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); |
|
83 | - |
|
84 | - if (!$suiteMethod->isStatic()) { |
|
85 | - $this->runFailed( |
|
86 | - 'suite() method must be static.' |
|
87 | - ); |
|
88 | - |
|
89 | - return; |
|
90 | - } |
|
91 | - |
|
92 | - try { |
|
93 | - $test = $suiteMethod->invoke(null, $testClass->getName()); |
|
94 | - } catch (ReflectionException $e) { |
|
95 | - $this->runFailed( |
|
96 | - \sprintf( |
|
97 | - "Failed to invoke suite() method.\n%s", |
|
98 | - $e->getMessage() |
|
99 | - ) |
|
100 | - ); |
|
101 | - |
|
102 | - return; |
|
103 | - } |
|
104 | - } catch (ReflectionException $e) { |
|
105 | - try { |
|
106 | - $test = new TestSuite($testClass); |
|
107 | - } catch (Exception $e) { |
|
108 | - $test = new TestSuite; |
|
109 | - $test->setName($suiteClassName); |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - $this->clearStatus(); |
|
114 | - |
|
115 | - return $test; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Returns the loaded ReflectionClass for a suite name. |
|
120 | - * |
|
121 | - * @param string $suiteClassName |
|
122 | - * @param string $suiteClassFile |
|
123 | - * |
|
124 | - * @return ReflectionClass |
|
125 | - */ |
|
126 | - protected function loadSuiteClass($suiteClassName, $suiteClassFile = '') |
|
127 | - { |
|
128 | - $loader = $this->getLoader(); |
|
129 | - |
|
130 | - return $loader->load($suiteClassName, $suiteClassFile); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Clears the status message. |
|
135 | - */ |
|
136 | - protected function clearStatus() |
|
137 | - { |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Override to define how to handle a failed loading of |
|
142 | - * a test suite. |
|
143 | - * |
|
144 | - * @param string $message |
|
145 | - */ |
|
146 | - abstract protected function runFailed($message); |
|
24 | + const STATUS_PASSED = 0; |
|
25 | + const STATUS_SKIPPED = 1; |
|
26 | + const STATUS_INCOMPLETE = 2; |
|
27 | + const STATUS_FAILURE = 3; |
|
28 | + const STATUS_ERROR = 4; |
|
29 | + const STATUS_RISKY = 5; |
|
30 | + const STATUS_WARNING = 6; |
|
31 | + const SUITE_METHODNAME = 'suite'; |
|
32 | + |
|
33 | + /** |
|
34 | + * Returns the loader to be used. |
|
35 | + * |
|
36 | + * @return TestSuiteLoader |
|
37 | + */ |
|
38 | + public function getLoader() |
|
39 | + { |
|
40 | + return new StandardTestSuiteLoader; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Returns the Test corresponding to the given suite. |
|
45 | + * This is a template method, subclasses override |
|
46 | + * the runFailed() and clearStatus() methods. |
|
47 | + * |
|
48 | + * @param string $suiteClassName |
|
49 | + * @param string $suiteClassFile |
|
50 | + * @param mixed $suffixes |
|
51 | + * |
|
52 | + * @return Test|null |
|
53 | + */ |
|
54 | + public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') |
|
55 | + { |
|
56 | + if (\is_dir($suiteClassName) && |
|
57 | + !\is_file($suiteClassName . '.php') && empty($suiteClassFile)) { |
|
58 | + $facade = new File_Iterator_Facade; |
|
59 | + $files = $facade->getFilesAsArray( |
|
60 | + $suiteClassName, |
|
61 | + $suffixes |
|
62 | + ); |
|
63 | + |
|
64 | + $suite = new TestSuite($suiteClassName); |
|
65 | + $suite->addTestFiles($files); |
|
66 | + |
|
67 | + return $suite; |
|
68 | + } |
|
69 | + |
|
70 | + try { |
|
71 | + $testClass = $this->loadSuiteClass( |
|
72 | + $suiteClassName, |
|
73 | + $suiteClassFile |
|
74 | + ); |
|
75 | + } catch (Exception $e) { |
|
76 | + $this->runFailed($e->getMessage()); |
|
77 | + |
|
78 | + return; |
|
79 | + } |
|
80 | + |
|
81 | + try { |
|
82 | + $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); |
|
83 | + |
|
84 | + if (!$suiteMethod->isStatic()) { |
|
85 | + $this->runFailed( |
|
86 | + 'suite() method must be static.' |
|
87 | + ); |
|
88 | + |
|
89 | + return; |
|
90 | + } |
|
91 | + |
|
92 | + try { |
|
93 | + $test = $suiteMethod->invoke(null, $testClass->getName()); |
|
94 | + } catch (ReflectionException $e) { |
|
95 | + $this->runFailed( |
|
96 | + \sprintf( |
|
97 | + "Failed to invoke suite() method.\n%s", |
|
98 | + $e->getMessage() |
|
99 | + ) |
|
100 | + ); |
|
101 | + |
|
102 | + return; |
|
103 | + } |
|
104 | + } catch (ReflectionException $e) { |
|
105 | + try { |
|
106 | + $test = new TestSuite($testClass); |
|
107 | + } catch (Exception $e) { |
|
108 | + $test = new TestSuite; |
|
109 | + $test->setName($suiteClassName); |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + $this->clearStatus(); |
|
114 | + |
|
115 | + return $test; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Returns the loaded ReflectionClass for a suite name. |
|
120 | + * |
|
121 | + * @param string $suiteClassName |
|
122 | + * @param string $suiteClassFile |
|
123 | + * |
|
124 | + * @return ReflectionClass |
|
125 | + */ |
|
126 | + protected function loadSuiteClass($suiteClassName, $suiteClassFile = '') |
|
127 | + { |
|
128 | + $loader = $this->getLoader(); |
|
129 | + |
|
130 | + return $loader->load($suiteClassName, $suiteClassFile); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Clears the status message. |
|
135 | + */ |
|
136 | + protected function clearStatus() |
|
137 | + { |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Override to define how to handle a failed loading of |
|
142 | + * a test suite. |
|
143 | + * |
|
144 | + * @param string $message |
|
145 | + */ |
|
146 | + abstract protected function runFailed($message); |
|
147 | 147 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') |
55 | 55 | { |
56 | 56 | if (\is_dir($suiteClassName) && |
57 | - !\is_file($suiteClassName . '.php') && empty($suiteClassFile)) { |
|
57 | + !\is_file($suiteClassName.'.php') && empty($suiteClassFile)) { |
|
58 | 58 | $facade = new File_Iterator_Facade; |
59 | 59 | $files = $facade->getFilesAsArray( |
60 | 60 | $suiteClassName, |
@@ -17,59 +17,59 @@ |
||
17 | 17 | */ |
18 | 18 | class Version |
19 | 19 | { |
20 | - private static $pharVersion; |
|
21 | - private static $version; |
|
20 | + private static $pharVersion; |
|
21 | + private static $version; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Returns the current version of PHPUnit. |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public static function id() |
|
29 | - { |
|
30 | - if (self::$pharVersion !== null) { |
|
31 | - return self::$pharVersion; |
|
32 | - } |
|
23 | + /** |
|
24 | + * Returns the current version of PHPUnit. |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public static function id() |
|
29 | + { |
|
30 | + if (self::$pharVersion !== null) { |
|
31 | + return self::$pharVersion; |
|
32 | + } |
|
33 | 33 | |
34 | - if (self::$version === null) { |
|
35 | - $version = new VersionId('6.4.4', \dirname(\dirname(__DIR__))); |
|
36 | - self::$version = $version->getVersion(); |
|
37 | - } |
|
34 | + if (self::$version === null) { |
|
35 | + $version = new VersionId('6.4.4', \dirname(\dirname(__DIR__))); |
|
36 | + self::$version = $version->getVersion(); |
|
37 | + } |
|
38 | 38 | |
39 | - return self::$version; |
|
40 | - } |
|
39 | + return self::$version; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public static function series() |
|
46 | - { |
|
47 | - if (\strpos(self::id(), '-')) { |
|
48 | - $version = \explode('-', self::id())[0]; |
|
49 | - } else { |
|
50 | - $version = self::id(); |
|
51 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public static function series() |
|
46 | + { |
|
47 | + if (\strpos(self::id(), '-')) { |
|
48 | + $version = \explode('-', self::id())[0]; |
|
49 | + } else { |
|
50 | + $version = self::id(); |
|
51 | + } |
|
52 | 52 | |
53 | - return \implode('.', \array_slice(\explode('.', $version), 0, 2)); |
|
54 | - } |
|
53 | + return \implode('.', \array_slice(\explode('.', $version), 0, 2)); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public static function getVersionString() |
|
60 | - { |
|
61 | - return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.'; |
|
62 | - } |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public static function getVersionString() |
|
60 | + { |
|
61 | + return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.'; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function getReleaseChannel() |
|
68 | - { |
|
69 | - if (\strpos(self::$pharVersion, '-') !== false) { |
|
70 | - return '-nightly'; |
|
71 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function getReleaseChannel() |
|
68 | + { |
|
69 | + if (\strpos(self::$pharVersion, '-') !== false) { |
|
70 | + return '-nightly'; |
|
71 | + } |
|
72 | 72 | |
73 | - return ''; |
|
74 | - } |
|
73 | + return ''; |
|
74 | + } |
|
75 | 75 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | */ |
59 | 59 | public static function getVersionString() |
60 | 60 | { |
61 | - return 'PHPUnit ' . self::id() . ' by Sebastian Bergmann and contributors.'; |
|
61 | + return 'PHPUnit '.self::id().' by Sebastian Bergmann and contributors.'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -15,47 +15,47 @@ |
||
15 | 15 | |
16 | 16 | abstract class GroupFilterIterator extends RecursiveFilterIterator |
17 | 17 | { |
18 | - /** |
|
19 | - * @var array |
|
20 | - */ |
|
21 | - protected $groupTests = []; |
|
22 | - |
|
23 | - /** |
|
24 | - * @param RecursiveIterator $iterator |
|
25 | - * @param array $groups |
|
26 | - * @param TestSuite $suite |
|
27 | - */ |
|
28 | - public function __construct(RecursiveIterator $iterator, array $groups, TestSuite $suite) |
|
29 | - { |
|
30 | - parent::__construct($iterator); |
|
31 | - |
|
32 | - foreach ($suite->getGroupDetails() as $group => $tests) { |
|
33 | - if (\in_array($group, $groups)) { |
|
34 | - $testHashes = \array_map( |
|
35 | - function ($test) { |
|
36 | - return \spl_object_hash($test); |
|
37 | - }, |
|
38 | - $tests |
|
39 | - ); |
|
40 | - |
|
41 | - $this->groupTests = \array_merge($this->groupTests, $testHashes); |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public function accept() |
|
50 | - { |
|
51 | - $test = $this->getInnerIterator()->current(); |
|
52 | - |
|
53 | - if ($test instanceof TestSuite) { |
|
54 | - return true; |
|
55 | - } |
|
56 | - |
|
57 | - return $this->doAccept(\spl_object_hash($test)); |
|
58 | - } |
|
59 | - |
|
60 | - abstract protected function doAccept($hash); |
|
18 | + /** |
|
19 | + * @var array |
|
20 | + */ |
|
21 | + protected $groupTests = []; |
|
22 | + |
|
23 | + /** |
|
24 | + * @param RecursiveIterator $iterator |
|
25 | + * @param array $groups |
|
26 | + * @param TestSuite $suite |
|
27 | + */ |
|
28 | + public function __construct(RecursiveIterator $iterator, array $groups, TestSuite $suite) |
|
29 | + { |
|
30 | + parent::__construct($iterator); |
|
31 | + |
|
32 | + foreach ($suite->getGroupDetails() as $group => $tests) { |
|
33 | + if (\in_array($group, $groups)) { |
|
34 | + $testHashes = \array_map( |
|
35 | + function ($test) { |
|
36 | + return \spl_object_hash($test); |
|
37 | + }, |
|
38 | + $tests |
|
39 | + ); |
|
40 | + |
|
41 | + $this->groupTests = \array_merge($this->groupTests, $testHashes); |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public function accept() |
|
50 | + { |
|
51 | + $test = $this->getInnerIterator()->current(); |
|
52 | + |
|
53 | + if ($test instanceof TestSuite) { |
|
54 | + return true; |
|
55 | + } |
|
56 | + |
|
57 | + return $this->doAccept(\spl_object_hash($test)); |
|
58 | + } |
|
59 | + |
|
60 | + abstract protected function doAccept($hash); |
|
61 | 61 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | foreach ($suite->getGroupDetails() as $group => $tests) { |
33 | 33 | if (\in_array($group, $groups)) { |
34 | 34 | $testHashes = \array_map( |
35 | - function ($test) { |
|
35 | + function($test) { |
|
36 | 36 | return \spl_object_hash($test); |
37 | 37 | }, |
38 | 38 | $tests |
@@ -17,39 +17,39 @@ |
||
17 | 17 | |
18 | 18 | class Factory |
19 | 19 | { |
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - private $filters = []; |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + private $filters = []; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param ReflectionClass $filter |
|
27 | - * @param mixed $args |
|
28 | - */ |
|
29 | - public function addFilter(ReflectionClass $filter, $args) |
|
30 | - { |
|
31 | - if (!$filter->isSubclassOf(\RecursiveFilterIterator::class)) { |
|
32 | - throw new InvalidArgumentException( |
|
33 | - \sprintf( |
|
34 | - 'Class "%s" does not extend RecursiveFilterIterator', |
|
35 | - $filter->name |
|
36 | - ) |
|
37 | - ); |
|
38 | - } |
|
25 | + /** |
|
26 | + * @param ReflectionClass $filter |
|
27 | + * @param mixed $args |
|
28 | + */ |
|
29 | + public function addFilter(ReflectionClass $filter, $args) |
|
30 | + { |
|
31 | + if (!$filter->isSubclassOf(\RecursiveFilterIterator::class)) { |
|
32 | + throw new InvalidArgumentException( |
|
33 | + \sprintf( |
|
34 | + 'Class "%s" does not extend RecursiveFilterIterator', |
|
35 | + $filter->name |
|
36 | + ) |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | |
40 | - $this->filters[] = [$filter, $args]; |
|
41 | - } |
|
40 | + $this->filters[] = [$filter, $args]; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return FilterIterator |
|
45 | - */ |
|
46 | - public function factory(Iterator $iterator, TestSuite $suite) |
|
47 | - { |
|
48 | - foreach ($this->filters as $filter) { |
|
49 | - list($class, $args) = $filter; |
|
50 | - $iterator = $class->newInstance($iterator, $args, $suite); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return FilterIterator |
|
45 | + */ |
|
46 | + public function factory(Iterator $iterator, TestSuite $suite) |
|
47 | + { |
|
48 | + foreach ($this->filters as $filter) { |
|
49 | + list($class, $args) = $filter; |
|
50 | + $iterator = $class->newInstance($iterator, $args, $suite); |
|
51 | + } |
|
52 | 52 | |
53 | - return $iterator; |
|
54 | - } |
|
53 | + return $iterator; |
|
54 | + } |
|
55 | 55 | } |
@@ -11,13 +11,13 @@ |
||
11 | 11 | |
12 | 12 | class IncludeGroupFilterIterator extends GroupFilterIterator |
13 | 13 | { |
14 | - /** |
|
15 | - * @param string $hash |
|
16 | - * |
|
17 | - * @return bool |
|
18 | - */ |
|
19 | - protected function doAccept($hash) |
|
20 | - { |
|
21 | - return \in_array($hash, $this->groupTests); |
|
22 | - } |
|
14 | + /** |
|
15 | + * @param string $hash |
|
16 | + * |
|
17 | + * @return bool |
|
18 | + */ |
|
19 | + protected function doAccept($hash) |
|
20 | + { |
|
21 | + return \in_array($hash, $this->groupTests); |
|
22 | + } |
|
23 | 23 | } |
@@ -17,108 +17,108 @@ |
||
17 | 17 | |
18 | 18 | class NameFilterIterator extends RecursiveFilterIterator |
19 | 19 | { |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $filter; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $filter; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var int |
|
27 | - */ |
|
28 | - protected $filterMin; |
|
29 | - /** |
|
30 | - * @var int |
|
31 | - */ |
|
32 | - protected $filterMax; |
|
25 | + /** |
|
26 | + * @var int |
|
27 | + */ |
|
28 | + protected $filterMin; |
|
29 | + /** |
|
30 | + * @var int |
|
31 | + */ |
|
32 | + protected $filterMax; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param RecursiveIterator $iterator |
|
36 | - * @param string $filter |
|
37 | - */ |
|
38 | - public function __construct(RecursiveIterator $iterator, $filter) |
|
39 | - { |
|
40 | - parent::__construct($iterator); |
|
41 | - $this->setFilter($filter); |
|
42 | - } |
|
34 | + /** |
|
35 | + * @param RecursiveIterator $iterator |
|
36 | + * @param string $filter |
|
37 | + */ |
|
38 | + public function __construct(RecursiveIterator $iterator, $filter) |
|
39 | + { |
|
40 | + parent::__construct($iterator); |
|
41 | + $this->setFilter($filter); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $filter |
|
46 | - */ |
|
47 | - protected function setFilter($filter) |
|
48 | - { |
|
49 | - if (RegularExpression::safeMatch($filter, '') === false) { |
|
50 | - // Handles: |
|
51 | - // * testAssertEqualsSucceeds#4 |
|
52 | - // * testAssertEqualsSucceeds#4-8 |
|
53 | - if (\preg_match('/^(.*?)#(\d+)(?:-(\d+))?$/', $filter, $matches)) { |
|
54 | - if (isset($matches[3]) && $matches[2] < $matches[3]) { |
|
55 | - $filter = \sprintf( |
|
56 | - '%s.*with data set #(\d+)$', |
|
57 | - $matches[1] |
|
58 | - ); |
|
44 | + /** |
|
45 | + * @param string $filter |
|
46 | + */ |
|
47 | + protected function setFilter($filter) |
|
48 | + { |
|
49 | + if (RegularExpression::safeMatch($filter, '') === false) { |
|
50 | + // Handles: |
|
51 | + // * testAssertEqualsSucceeds#4 |
|
52 | + // * testAssertEqualsSucceeds#4-8 |
|
53 | + if (\preg_match('/^(.*?)#(\d+)(?:-(\d+))?$/', $filter, $matches)) { |
|
54 | + if (isset($matches[3]) && $matches[2] < $matches[3]) { |
|
55 | + $filter = \sprintf( |
|
56 | + '%s.*with data set #(\d+)$', |
|
57 | + $matches[1] |
|
58 | + ); |
|
59 | 59 | |
60 | - $this->filterMin = $matches[2]; |
|
61 | - $this->filterMax = $matches[3]; |
|
62 | - } else { |
|
63 | - $filter = \sprintf( |
|
64 | - '%s.*with data set #%s$', |
|
65 | - $matches[1], |
|
66 | - $matches[2] |
|
67 | - ); |
|
68 | - } |
|
69 | - } // Handles: |
|
70 | - // * testDetermineJsonError@JSON_ERROR_NONE |
|
71 | - // * testDetermineJsonError@JSON.* |
|
72 | - elseif (\preg_match('/^(.*?)@(.+)$/', $filter, $matches)) { |
|
73 | - $filter = \sprintf( |
|
74 | - '%s.*with data set "%s"$', |
|
75 | - $matches[1], |
|
76 | - $matches[2] |
|
77 | - ); |
|
78 | - } |
|
60 | + $this->filterMin = $matches[2]; |
|
61 | + $this->filterMax = $matches[3]; |
|
62 | + } else { |
|
63 | + $filter = \sprintf( |
|
64 | + '%s.*with data set #%s$', |
|
65 | + $matches[1], |
|
66 | + $matches[2] |
|
67 | + ); |
|
68 | + } |
|
69 | + } // Handles: |
|
70 | + // * testDetermineJsonError@JSON_ERROR_NONE |
|
71 | + // * testDetermineJsonError@JSON.* |
|
72 | + elseif (\preg_match('/^(.*?)@(.+)$/', $filter, $matches)) { |
|
73 | + $filter = \sprintf( |
|
74 | + '%s.*with data set "%s"$', |
|
75 | + $matches[1], |
|
76 | + $matches[2] |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | - // Escape delimiters in regular expression. Do NOT use preg_quote, |
|
81 | - // to keep magic characters. |
|
82 | - $filter = \sprintf('/%s/', \str_replace( |
|
83 | - '/', |
|
84 | - '\\/', |
|
85 | - $filter |
|
86 | - )); |
|
87 | - } |
|
80 | + // Escape delimiters in regular expression. Do NOT use preg_quote, |
|
81 | + // to keep magic characters. |
|
82 | + $filter = \sprintf('/%s/', \str_replace( |
|
83 | + '/', |
|
84 | + '\\/', |
|
85 | + $filter |
|
86 | + )); |
|
87 | + } |
|
88 | 88 | |
89 | - $this->filter = $filter; |
|
90 | - } |
|
89 | + $this->filter = $filter; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @return bool |
|
94 | - */ |
|
95 | - public function accept() |
|
96 | - { |
|
97 | - $test = $this->getInnerIterator()->current(); |
|
92 | + /** |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | + public function accept() |
|
96 | + { |
|
97 | + $test = $this->getInnerIterator()->current(); |
|
98 | 98 | |
99 | - if ($test instanceof TestSuite) { |
|
100 | - return true; |
|
101 | - } |
|
99 | + if ($test instanceof TestSuite) { |
|
100 | + return true; |
|
101 | + } |
|
102 | 102 | |
103 | - $tmp = \PHPUnit\Util\Test::describe($test, false); |
|
103 | + $tmp = \PHPUnit\Util\Test::describe($test, false); |
|
104 | 104 | |
105 | - if ($test instanceof WarningTestCase) { |
|
106 | - $name = $test->getMessage(); |
|
107 | - } else { |
|
108 | - if ($tmp[0] != '') { |
|
109 | - $name = \implode('::', $tmp); |
|
110 | - } else { |
|
111 | - $name = $tmp[1]; |
|
112 | - } |
|
113 | - } |
|
105 | + if ($test instanceof WarningTestCase) { |
|
106 | + $name = $test->getMessage(); |
|
107 | + } else { |
|
108 | + if ($tmp[0] != '') { |
|
109 | + $name = \implode('::', $tmp); |
|
110 | + } else { |
|
111 | + $name = $tmp[1]; |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - $accepted = @\preg_match($this->filter, $name, $matches); |
|
115 | + $accepted = @\preg_match($this->filter, $name, $matches); |
|
116 | 116 | |
117 | - if ($accepted && isset($this->filterMax)) { |
|
118 | - $set = \end($matches); |
|
119 | - $accepted = $set >= $this->filterMin && $set <= $this->filterMax; |
|
120 | - } |
|
117 | + if ($accepted && isset($this->filterMax)) { |
|
118 | + $set = \end($matches); |
|
119 | + $accepted = $set >= $this->filterMin && $set <= $this->filterMax; |
|
120 | + } |
|
121 | 121 | |
122 | - return $accepted; |
|
123 | - } |
|
122 | + return $accepted; |
|
123 | + } |
|
124 | 124 | } |
@@ -11,13 +11,13 @@ |
||
11 | 11 | |
12 | 12 | class ExcludeGroupFilterIterator extends GroupFilterIterator |
13 | 13 | { |
14 | - /** |
|
15 | - * @param string $hash |
|
16 | - * |
|
17 | - * @return bool |
|
18 | - */ |
|
19 | - protected function doAccept($hash) |
|
20 | - { |
|
21 | - return !\in_array($hash, $this->groupTests); |
|
22 | - } |
|
14 | + /** |
|
15 | + * @param string $hash |
|
16 | + * |
|
17 | + * @return bool |
|
18 | + */ |
|
19 | + protected function doAccept($hash) |
|
20 | + { |
|
21 | + return !\in_array($hash, $this->groupTests); |
|
22 | + } |
|
23 | 23 | } |