Mercurial > hg > cmmr2012-drupal-site
comparison vendor/squizlabs/php_codesniffer/tests/bootstrap.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | |
children | 12f9dff5fda9 |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
1 <?php | |
2 /** | |
3 * Bootstrap file for PHP_CodeSniffer unit tests. | |
4 * | |
5 * @author Greg Sherwood <gsherwood@squiz.net> | |
6 * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600) | |
7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | |
8 */ | |
9 | |
10 if (defined('PHP_CODESNIFFER_IN_TESTS') === false) { | |
11 define('PHP_CODESNIFFER_IN_TESTS', true); | |
12 } | |
13 | |
14 if (defined('PHP_CODESNIFFER_CBF') === false) { | |
15 define('PHP_CODESNIFFER_CBF', false); | |
16 } | |
17 | |
18 if (defined('PHP_CODESNIFFER_VERBOSITY') === false) { | |
19 define('PHP_CODESNIFFER_VERBOSITY', 0); | |
20 } | |
21 | |
22 if (is_file(__DIR__.'/../autoload.php') === true) { | |
23 include_once __DIR__.'/../autoload.php'; | |
24 } else { | |
25 include_once 'PHP/CodeSniffer/autoload.php'; | |
26 } | |
27 | |
28 $tokens = new \PHP_CodeSniffer\Util\Tokens(); | |
29 | |
30 // Compatibility for PHPUnit < 6 and PHPUnit 6+. | |
31 if (class_exists('PHPUnit_Framework_TestSuite') === true && class_exists('PHPUnit\Framework\TestSuite') === false) { | |
32 class_alias('PHPUnit_Framework_TestSuite', 'PHPUnit'.'\Framework\TestSuite'); | |
33 } | |
34 | |
35 if (class_exists('PHPUnit_Framework_TestCase') === true && class_exists('PHPUnit\Framework\TestCase') === false) { | |
36 class_alias('PHPUnit_Framework_TestCase', 'PHPUnit'.'\Framework\TestCase'); | |
37 } | |
38 | |
39 if (class_exists('PHPUnit_TextUI_TestRunner') === true && class_exists('PHPUnit\TextUI\TestRunner') === false) { | |
40 class_alias('PHPUnit_TextUI_TestRunner', 'PHPUnit'.'\TextUI\TestRunner'); | |
41 } | |
42 | |
43 if (class_exists('PHPUnit_Framework_TestResult') === true && class_exists('PHPUnit\Framework\TestResult') === false) { | |
44 class_alias('PHPUnit_Framework_TestResult', 'PHPUnit'.'\Framework\TestResult'); | |
45 } | |
46 | |
47 | |
48 /** | |
49 * A global util function to help print unit test fixing data. | |
50 * | |
51 * @return void | |
52 */ | |
53 function printPHPCodeSnifferTestOutput() | |
54 { | |
55 $codeCount = count($GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']); | |
56 $files = call_user_func_array('array_merge', $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES']); | |
57 $files = array_unique($files); | |
58 $fileCount = count($files); | |
59 | |
60 echo PHP_EOL.PHP_EOL; | |
61 echo "$fileCount sniff test files generated $codeCount unique error codes"; | |
62 if ($codeCount > 0) { | |
63 $fixes = count($GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']); | |
64 $percent = round(($fixes / $codeCount * 100), 2); | |
65 echo "; $fixes were fixable ($percent%)"; | |
66 } | |
67 | |
68 }//end printPHPCodeSnifferTestOutput() |