|
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=PSR1 -n src tests *.php', $returnStatus); |
12 | | -if ($returnStatus !== 0) { |
| 11 | +require 'vendor/autoload.php'; |
| 12 | + |
| 13 | +$phpcsCLI = new PHP_CodeSniffer_CLI(); |
| 14 | +$phpcsArguments = array('standard' => array('PSR1'), 'files' => array('src', 'tests', 'build.php'), 'warningSeverity' => 0); |
| 15 | +$phpcsViolations = $phpcsCLI->process($phpcsArguments); |
| 16 | +if ($phpcsViolations > 0) { |
13 | 17 | exit(1); |
14 | 18 | } |
15 | 19 |
|
16 | | -passthru('./vendor/bin/phpunit --coverage-html coverage --strict tests', $returnStatus); |
17 | | -if ($returnStatus !== 0) { |
| 20 | +$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml'); |
| 21 | +$phpunitArguments = array('coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration); |
| 22 | +$testRunner = new PHPUnit_TextUI_TestRunner(); |
| 23 | +$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments); |
| 24 | +if (!$result->wasSuccessful()) { |
18 | 25 | exit(1); |
19 | 26 | } |
| 27 | + |
| 28 | +$coverageFactory = new PHP_CodeCoverage_Report_Factory(); |
| 29 | +$coverageReport = $coverageFactory->create($result->getCodeCoverage()); |
| 30 | +if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) { |
| 31 | + file_put_contents('php://stderr', "Code coverage was NOT 100%\n"); |
| 32 | + exit(1); |
| 33 | +} |
| 34 | + |
| 35 | +echo "Code coverage was 100%\n"; |
0 commit comments