/** * First runs PHPUnit and then post processes the generated coverage data * to calculate the change coverage. * * @param array(string) $argv The raw command line arguments. * * @return integer */ public function run(array $argv) { $this->printVersionString(); try { $this->handleArguments($argv); $arguments = $this->extractPhpunitArguments($argv); } catch (InvalidArgumentException $e) { $exception = $e->getMessage(); $arguments = array('--help'); } $phpunit = new PHP_ChangeCoverage_PHPUnit($this->phpunitBinary); $phpunit->run($arguments); if ($phpunit->isHelp()) { $this->writeLine(); $this->writeLine(); $this->writeLine('Additional options added by PHP_ChangeCoverage'); $this->writeLine(); $this->writeLine(' --temp-dir Temporary directory for generated runtime data.'); $this->writeLine(' --phpunit-binary Optional path to phpunit\'s binary.'); $this->writeLine(' --modified-since Cover only lines that were changed since this date.'); $this->writeLine(' This option accepts textual date expressions.'); $this->writeLine(' --unmodified-as-covered Mark all unmodified lines as covered.'); if (isset($exception)) { $this->writeLine(); $this->writeLine($exception); return 2; } } else { if (file_exists($this->temporaryClover)) { PHP_Timer::start(); $report = $this->createCoverageReport(); $codeCoverage = $this->rebuildCoverageData($report); $this->writeCoverageClover($codeCoverage); $this->writeCoverageHtml($codeCoverage); PHP_Timer::stop(); $this->writeLine(PHP_Timer::resourceUsage()); unlink($this->temporaryClover); } } return $phpunit->getExitCode(); }
/** * testDefaultExitCodeIsZero * * @return void * @covers PHP_ChangeCoverage_PHPUnit * @group unittest */ public function testDefaultExitCodeIsZero() { $phpunit = new PHP_ChangeCoverage_PHPUnit(__FILE__); self::assertEquals(0, $phpunit->getExitCode()); }