forked from squizlabs/PHP_CodeSniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestSuite.php
66 lines (56 loc) · 2.13 KB
/
TestSuite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* A PHP_CodeSniffer specific test suite for PHPUnit.
*
* PHP version 5
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <[email protected]>
* @author Marc McIntyre <[email protected]>
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
/**
* A PHP_CodeSniffer specific test suite for PHPUnit.
*
* Unregisters the PHP_CodeSniffer autoload function after the run.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood <[email protected]>
* @author Marc McIntyre <[email protected]>
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
* @version Release: @package_version@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class PHP_CodeSniffer_TestSuite extends PHPUnit_Framework_TestSuite
{
/**
* Runs the tests and collects their result in a TestResult.
*
* @param PHPUnit_Framework_TestResult $result A test result.
* @param mixed $filter The filter passed to each test.
*
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result=null, $filter=false)
{
$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = array();
$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = array();
spl_autoload_register(array('PHP_CodeSniffer', 'autoload'));
$result = parent::run($result, $filter);
spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload'));
$codes = count($GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']);
echo PHP_EOL.PHP_EOL;
echo "Tests generated $codes unique error codes";
if ($codes > 0) {
$fixes = count($GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']);
$percent = round(($fixes / $codes * 100), 2);
echo "; $fixes were fixable ($percent%)";
}
return $result;
}//end run()
}//end class