|
3 | 3 | chdir(__DIR__); |
4 | 4 |
|
5 | 5 | $returnStatus = null; |
6 | | -passthru('composer install --dev', $returnStatus); |
| 6 | +passthru('composer install', $returnStatus); |
7 | 7 | if ($returnStatus !== 0) { |
8 | 8 | exit(1); |
9 | 9 | } |
10 | 10 |
|
11 | | -passthru('./vendor/bin/phpcs --standard=' . __DIR__ . '/vendor/dominionenterprises/dws-coding-standard/DWS -n src tests *.php', $returnStatus); |
12 | | -if ($returnStatus !== 0) { |
| 11 | +require 'vendor/autoload.php'; |
| 12 | + |
| 13 | +$phpcsCLI = new PHP_CodeSniffer_CLI(); |
| 14 | +$phpcsArguments = array( |
| 15 | + 'standard' => array(__DIR__ . '/vendor/dominionenterprises/dws-coding-standard/DWS'), |
| 16 | + 'files' => array('src', 'tests', 'build.php'), |
| 17 | + 'warningSeverity' => 0, |
| 18 | +); |
| 19 | +$phpcsViolations = $phpcsCLI->process($phpcsArguments); |
| 20 | +if ($phpcsViolations > 0) { |
13 | 21 | exit(1); |
14 | 22 | } |
15 | 23 |
|
16 | | -passthru('vendor/bin/phpunit --coverage-html coverage --coverage-clover clover.xml tests', $returnStatus); |
17 | | -if ($returnStatus !== 0) { |
| 24 | +$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml'); |
| 25 | +$phpunitArguments = array('coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration); |
| 26 | +$testRunner = new PHPUnit_TextUI_TestRunner(); |
| 27 | +$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments); |
| 28 | +if (!$result->wasSuccessful()) { |
18 | 29 | exit(1); |
19 | 30 | } |
20 | 31 |
|
21 | | -$xml = new SimpleXMLElement(file_get_contents('clover.xml')); |
22 | | -foreach ($xml->xpath('//file/metrics') as $metric) { |
23 | | - if ((int)$metric['elements'] !== (int)$metric['coveredelements']) { |
24 | | - file_put_contents('php://stderr', "Code coverage was NOT 100%\n"); |
25 | | - exit(1); |
26 | | - } |
| 32 | +$coverageFactory = new PHP_CodeCoverage_Report_Factory(); |
| 33 | +$coverageReport = $coverageFactory->create($result->getCodeCoverage()); |
| 34 | +if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) { |
| 35 | + file_put_contents('php://stderr', "Code coverage was NOT 100%\n"); |
| 36 | + exit(1); |
27 | 37 | } |
28 | 38 |
|
29 | 39 | echo "Code coverage was 100%\n"; |
0 commit comments