function it_should_output_text_report(\PHP_CodeCoverage $coverage, \PHP_CodeCoverage_Report_Text $text, SuiteEvent $event, IO $io)
 {
     $reports = array('text' => $text);
     $this->beConstructedWith($coverage, $reports);
     $this->setOptions(array('format' => 'text'));
     $io->isVerbose()->willReturn(false);
     $this->setIO($io);
     $text->process($coverage, true)->willReturn('report');
     $io->writeln('report')->shouldBeCalled();
     $this->afterSuite($event);
 }
Ejemplo n.º 2
0
 /**
  * @param  PHPUnit_Framework_Test       $suite
  * @param  array                        $arguments
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     $this->processSuiteFilters($suite, $arguments);
     if (isset($arguments['bootstrap'])) {
         $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
     }
     if ($arguments['backupGlobals'] === false) {
         $suite->setBackupGlobals(false);
     }
     if ($arguments['backupStaticAttributes'] === true) {
         $suite->setBackupStaticAttributes(true);
     }
     if ($arguments['disallowChangesToGlobalState'] === true) {
         $suite->setDisallowChangesToGlobalState(true);
     }
     if (is_integer($arguments['repeat'])) {
         $test = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['processIsolation']);
         $suite = new PHPUnit_Framework_TestSuite();
         $suite->addTest($test);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(false);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = false;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = false;
     }
     if ($arguments['stopOnError']) {
         $result->stopOnError(true);
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(true);
     }
     if ($arguments['stopOnIncomplete']) {
         $result->stopOnIncomplete(true);
     }
     if ($arguments['stopOnRisky']) {
         $result->stopOnRisky(true);
     }
     if ($arguments['stopOnSkipped']) {
         $result->stopOnSkipped(true);
     }
     if ($this->printer === null) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $printerClass = 'PHPUnit_TextUI_ResultPrinter';
             if (isset($arguments['printer']) && is_string($arguments['printer']) && class_exists($arguments['printer'], false)) {
                 $class = new ReflectionClass($arguments['printer']);
                 if ($class->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
                     $printerClass = $arguments['printer'];
                 }
             }
             $this->printer = new $printerClass(isset($arguments['stderr']) ? 'php://stderr' : null, $arguments['verbose'], $arguments['colors'], $arguments['debug'], $arguments['columns']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n");
         self::$versionStringPrinted = true;
         if ($arguments['verbose']) {
             $this->printer->write(sprintf("\nRuntime:\t%s", $this->runtime->getNameWithVersion()));
             if ($this->runtime->hasXdebug()) {
                 $this->printer->write(sprintf(" with Xdebug %s", phpversion('xdebug')));
             }
             if (isset($arguments['configuration'])) {
                 $this->printer->write(sprintf("\nConfiguration:\t%s", $arguments['configuration']->getFilename()));
             }
             $this->printer->write("\n");
         }
         if (isset($arguments['deprecatedStrictModeOption'])) {
             print "Warning:\tDeprecated option \"--strict\" used\n";
         } elseif (isset($arguments['deprecatedStrictModeSetting'])) {
             print "Warning:\tDeprecated configuration setting \"strict\" used\n";
         }
         if (isset($arguments['deprecatedSeleniumConfiguration'])) {
             print "Warning:\tDeprecated configuration setting \"selenium\" used\n";
         }
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if (isset($arguments['testdoxHTMLFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     $codeCoverageReports = 0;
     if (isset($arguments['coverageClover'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageCrap4J'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageHtml'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coveragePHP'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageText'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageXml'])) {
         $codeCoverageReports++;
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         if ($codeCoverageReports > 0 && !$this->codeCoverageFilter->hasWhitelist()) {
             $this->printer->write("Warning:\tNo whitelist configured for code coverage\n");
         }
         $this->printer->write("\n");
     }
     if ($codeCoverageReports > 0 && (!extension_loaded('tokenizer') || !$this->runtime->canCollectCodeCoverage())) {
         if (!extension_loaded('tokenizer')) {
             $this->showExtensionNotLoadedMessage('tokenizer', 'No code coverage will be generated.');
         } elseif (!extension_loaded('Xdebug')) {
             $this->showExtensionNotLoadedMessage('Xdebug', 'No code coverage will be generated.');
         }
         $codeCoverageReports = 0;
     }
     if ($codeCoverageReports > 0) {
         $codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
         $codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
         $codeCoverage->setCheckForUnintentionallyCoveredCode($arguments['strictCoverage']);
         $codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
         if (isset($arguments['forceCoversAnnotation'])) {
             $codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
         }
         if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
             $codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
         }
         $result->setCodeCoverage($codeCoverage);
     }
     if ($codeCoverageReports > 1) {
         if (isset($arguments['cacheTokens'])) {
             $codeCoverage->setCacheTokens($arguments['cacheTokens']);
         }
     }
     if (isset($arguments['jsonLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['junitLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
     }
     $result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
     $result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
     $result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
     $result->beStrictAboutTestSize($arguments['enforceTimeLimit']);
     $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
     $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
     $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
     if ($suite instanceof PHPUnit_Framework_TestSuite) {
         $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
     }
     $suite->run($result);
     unset($suite);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (isset($codeCoverage)) {
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nGenerating code coverage report in Clover XML format ...");
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($codeCoverage, $arguments['coverageClover']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coverageCrap4J'])) {
             $this->printer->write("\nGenerating Crap4J report XML file ...");
             $writer = new PHP_CodeCoverage_Report_Crap4j();
             $writer->process($codeCoverage, $arguments['coverageCrap4J']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coverageHtml'])) {
             $this->printer->write("\nGenerating code coverage report in HTML format ...");
             $writer = new PHP_CodeCoverage_Report_HTML($arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], sprintf(' and <a href="http://phpunit.de/">PHPUnit %s</a>', PHPUnit_Runner_Version::id()));
             $writer->process($codeCoverage, $arguments['coverageHtml']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coveragePHP'])) {
             $this->printer->write("\nGenerating code coverage report in PHP format ...");
             $writer = new PHP_CodeCoverage_Report_PHP();
             $writer->process($codeCoverage, $arguments['coveragePHP']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coverageText'])) {
             if ($arguments['coverageText'] == 'php://stdout') {
                 $outputStream = $this->printer;
                 $colors = $arguments['colors'];
             } else {
                 $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
                 $colors = false;
             }
             $processor = new PHP_CodeCoverage_Report_Text($arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles'], $arguments['coverageTextShowOnlySummary']);
             $outputStream->write($processor->process($codeCoverage, $colors));
         }
         if (isset($arguments['coverageXml'])) {
             $this->printer->write("\nGenerating code coverage report in PHPUnit XML format ...");
             $writer = new PHP_CodeCoverage_Report_XML();
             $writer->process($codeCoverage, $arguments['coverageXml']);
             $this->printer->write(" done\n");
             unset($writer);
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * @param PHPUnit_Framework_Test $suite
  * @param array                  $arguments
  * @param bool                   $exit
  *
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = [], $exit)
 {
     if (isset($arguments['configuration'])) {
         $GLOBALS['__PHPUNIT_CONFIGURATION_FILE'] = $arguments['configuration'];
     }
     $this->handleConfiguration($arguments);
     $this->processSuiteFilters($suite, $arguments);
     if (isset($arguments['bootstrap'])) {
         $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
     }
     if ($arguments['backupGlobals'] === false) {
         $suite->setBackupGlobals(false);
     }
     if ($arguments['backupStaticAttributes'] === true) {
         $suite->setBackupStaticAttributes(true);
     }
     if ($arguments['beStrictAboutChangesToGlobalState'] === true) {
         $suite->setbeStrictAboutChangesToGlobalState(true);
     }
     if (is_integer($arguments['repeat'])) {
         $test = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['processIsolation']);
         $suite = new PHPUnit_Framework_TestSuite();
         $suite->addTest($test);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(false);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = false;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = false;
     }
     if ($arguments['stopOnError']) {
         $result->stopOnError(true);
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(true);
     }
     if ($arguments['stopOnWarning']) {
         $result->stopOnWarning(true);
     }
     if ($arguments['stopOnIncomplete']) {
         $result->stopOnIncomplete(true);
     }
     if ($arguments['stopOnRisky']) {
         $result->stopOnRisky(true);
     }
     if ($arguments['stopOnSkipped']) {
         $result->stopOnSkipped(true);
     }
     if ($this->printer === null) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $printerClass = 'PHPUnit_TextUI_ResultPrinter';
             if (isset($arguments['printer']) && is_string($arguments['printer']) && class_exists($arguments['printer'], false)) {
                 $class = new ReflectionClass($arguments['printer']);
                 if ($class->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
                     $printerClass = $arguments['printer'];
                 }
             }
             $this->printer = new $printerClass(isset($arguments['stderr']) ? 'php://stderr' : null, $arguments['verbose'], $arguments['colors'], $arguments['debug'], $arguments['columns'], $arguments['reverseList']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n");
         self::$versionStringPrinted = true;
         if ($arguments['verbose']) {
             $runtime = $this->runtime->getNameWithVersion();
             if ($this->runtime->hasXdebug()) {
                 $runtime .= sprintf(' with Xdebug %s', phpversion('xdebug'));
             }
             $this->writeMessage('Runtime', $runtime);
             if (isset($arguments['configuration'])) {
                 $this->writeMessage('Configuration', $arguments['configuration']->getFilename());
             }
         }
         if (isset($arguments['deprecatedCheckForUnintentionallyCoveredCodeSettingUsed'])) {
             print "Warning:       Deprecated configuration setting \"checkForUnintentionallyCoveredCode\" used\n";
         }
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if (isset($arguments['testdoxHTMLFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     $codeCoverageReports = 0;
     if (isset($arguments['coverageClover'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageCrap4J'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageHtml'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coveragePHP'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageText'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['coverageXml'])) {
         $codeCoverageReports++;
     }
     if (isset($arguments['noCoverage'])) {
         $codeCoverageReports = 0;
     }
     if ($codeCoverageReports > 0) {
         if (!$this->runtime->canCollectCodeCoverage()) {
             $this->writeMessage('Error', 'No code coverage driver is available');
             $codeCoverageReports = 0;
         } elseif (!isset($arguments['whitelist']) && !$this->codeCoverageFilter->hasWhitelist()) {
             $this->writeMessage('Error', 'No whitelist configured, no code coverage will be generated');
             $codeCoverageReports = 0;
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write("\n");
     }
     if ($codeCoverageReports > 0) {
         $codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
         $codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
         $codeCoverage->setCheckForUnintentionallyCoveredCode($arguments['strictCoverage']);
         $codeCoverage->setCheckForUnexecutedCoveredCode($arguments['strictCoverage']);
         $codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
         if (isset($arguments['forceCoversAnnotation'])) {
             $codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
         }
         if (isset($arguments['disableCodeCoverageIgnore'])) {
             $codeCoverage->setDisableIgnoredLines(true);
         }
         if (isset($arguments['whitelist'])) {
             $this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']);
         }
         $result->setCodeCoverage($codeCoverage);
     }
     if ($codeCoverageReports > 1) {
         if (isset($arguments['cacheTokens'])) {
             $codeCoverage->setCacheTokens($arguments['cacheTokens']);
         }
     }
     if (isset($arguments['jsonLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['teamcityLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TeamCity($arguments['teamcityLogfile']));
     }
     if (isset($arguments['junitLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
     }
     $result->beStrictAboutTestsThatDoNotTestAnything($arguments['reportUselessTests']);
     $result->beStrictAboutOutputDuringTests($arguments['disallowTestOutput']);
     $result->beStrictAboutTodoAnnotatedTests($arguments['disallowTodoAnnotatedTests']);
     $result->beStrictAboutResourceUsageDuringSmallTests($arguments['beStrictAboutResourceUsageDuringSmallTests']);
     $result->enforceTimeLimit($arguments['enforceTimeLimit']);
     $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
     $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
     $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
     if ($suite instanceof PHPUnit_Framework_TestSuite) {
         $suite->setRunTestInSeparateProcess($arguments['processIsolation']);
     }
     $suite->run($result);
     unset($suite);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (isset($codeCoverage)) {
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nGenerating code coverage report in Clover XML format ...");
             try {
                 $writer = new PHP_CodeCoverage_Report_Clover();
                 $writer->process($codeCoverage, $arguments['coverageClover']);
                 $this->printer->write(" done\n");
                 unset($writer);
             } catch (PHP_CodeCoverage_Exception $e) {
                 $this->printer->write(" failed\n" . $e->getMessage() . "\n");
             }
         }
         if (isset($arguments['coverageCrap4J'])) {
             $this->printer->write("\nGenerating Crap4J report XML file ...");
             try {
                 $writer = new PHP_CodeCoverage_Report_Crap4j($arguments['crap4jThreshold']);
                 $writer->process($codeCoverage, $arguments['coverageCrap4J']);
                 $this->printer->write(" done\n");
                 unset($writer);
             } catch (PHP_CodeCoverage_Exception $e) {
                 $this->printer->write(" failed\n" . $e->getMessage() . "\n");
             }
         }
         if (isset($arguments['coverageHtml'])) {
             $this->printer->write("\nGenerating code coverage report in HTML format ...");
             try {
                 $writer = new PHP_CodeCoverage_Report_HTML($arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], sprintf(' and <a href="https://phpunit.de/">PHPUnit %s</a>', PHPUnit_Runner_Version::id()));
                 $writer->process($codeCoverage, $arguments['coverageHtml']);
                 $this->printer->write(" done\n");
                 unset($writer);
             } catch (PHP_CodeCoverage_Exception $e) {
                 $this->printer->write(" failed\n" . $e->getMessage() . "\n");
             }
         }
         if (isset($arguments['coveragePHP'])) {
             $this->printer->write("\nGenerating code coverage report in PHP format ...");
             try {
                 $writer = new PHP_CodeCoverage_Report_PHP();
                 $writer->process($codeCoverage, $arguments['coveragePHP']);
                 $this->printer->write(" done\n");
                 unset($writer);
             } catch (PHP_CodeCoverage_Exception $e) {
                 $this->printer->write(" failed\n" . $e->getMessage() . "\n");
             }
         }
         if (isset($arguments['coverageText'])) {
             if ($arguments['coverageText'] == 'php://stdout') {
                 $outputStream = $this->printer;
                 $colors = $arguments['colors'] && $arguments['colors'] != PHPUnit_TextUI_ResultPrinter::COLOR_NEVER;
             } else {
                 $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
                 $colors = false;
             }
             $processor = new PHP_CodeCoverage_Report_Text($arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles'], $arguments['coverageTextShowOnlySummary']);
             $outputStream->write($processor->process($codeCoverage, $colors));
         }
         if (isset($arguments['coverageXml'])) {
             $this->printer->write("\nGenerating code coverage report in PHPUnit XML format ...");
             try {
                 $writer = new PHP_CodeCoverage_Report_XML();
                 $writer->process($codeCoverage, $arguments['coverageXml']);
                 $this->printer->write(" done\n");
                 unset($writer);
             } catch (PHP_CodeCoverage_Exception $e) {
                 $this->printer->write(" failed\n" . $e->getMessage() . "\n");
             }
         }
     }
     if ($exit) {
         if ($result->wasSuccessful()) {
             if ($arguments['failOnRisky'] && !$result->allHarmless()) {
                 exit(self::FAILURE_EXIT);
             }
             if ($arguments['failOnWarning'] && $result->warningCount() > 0) {
                 exit(self::FAILURE_EXIT);
             }
             exit(self::SUCCESS_EXIT);
         }
         if ($result->errorCount() > 0) {
             exit(self::EXCEPTION_EXIT);
         }
         if ($result->failureCount() > 0) {
             exit(self::FAILURE_EXIT);
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Main method.
  */
 public function main()
 {
     $input = new \ezcConsoleInput();
     $input->registerOption(new \ezcConsoleOption('', 'clover', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'configuration', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'html', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'php', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'text', \ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new \ezcConsoleOption('', 'blacklist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'whitelist', \ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new \ezcConsoleOption('', 'merge', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('', 'add-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('', 'process-uncovered', \ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new \ezcConsoleOption('h', 'help', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new \ezcConsoleOption('v', 'version', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         $this->showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             $this->printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $configuration = $input->getOption('configuration')->value;
     $html = $input->getOption('html')->value;
     $php = $input->getOption('php')->value;
     $text = $input->getOption('text')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $addUncovered = $input->getOption('add-uncovered')->value;
     $processUncovered = $input->getOption('process-uncovered')->value;
     $merge = $input->getOption('merge')->value;
     $coverage = new \PHP_CodeCoverage();
     $filter = $coverage->filter();
     if ($configuration) {
         $this->handleConfiguration($configuration, $coverage);
     }
     if (count($arguments) == 1) {
         $this->printVersionString();
         if (empty($whitelist)) {
             $c = new \ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new \ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             $coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
             $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $facade = new \File_Iterator_Facade();
             $files = $facade->getFilesAsArray($arguments[0], '.cov');
             foreach ($files as $file) {
                 $coverage->merge(unserialize(file_get_contents($file)));
             }
         }
         if ($clover) {
             print "\nGenerating code coverage report in Clover XML format ...";
             $writer = new \PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
             print " done\n";
         }
         if ($html) {
             print "\nGenerating code coverage report in HTML format ...";
             $writer = new \PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
             print " done\n";
         }
         if ($php) {
             print "\nGenerating code coverage report in PHP format ...";
             $writer = new \PHP_CodeCoverage_Report_PHP();
             $writer->process($coverage, $php);
             print " done\n";
         }
         if ($text) {
             $writer = new \PHP_CodeCoverage_Report_Text();
             $writer->process($coverage, $text);
         }
     } else {
         $this->showHelp();
         exit(1);
     }
 }
Ejemplo n.º 5
0
 /**
  * @param  PHPUnit_Framework_Test $suite
  * @param  array                  $arguments
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     if (isset($arguments['bootstrap'])) {
         $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
     }
     if ($arguments['backupGlobals'] === FALSE) {
         $suite->setBackupGlobals(FALSE);
     }
     if ($arguments['backupStaticAttributes'] === TRUE) {
         $suite->setBackupStaticAttributes(TRUE);
     }
     if (is_integer($arguments['repeat'])) {
         $suite = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(FALSE);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = FALSE;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = FALSE;
     }
     if ($arguments['stopOnError']) {
         $result->stopOnError(TRUE);
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(TRUE);
     }
     if ($arguments['stopOnIncomplete']) {
         $result->stopOnIncomplete(TRUE);
     }
     if ($arguments['stopOnSkipped']) {
         $result->stopOnSkipped(TRUE);
     }
     if ($this->printer === NULL) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP && !self::$versionStringPrinted) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
         if (isset($arguments['configuration'])) {
             $this->printer->write(sprintf("Configuration read from %s\n\n", $arguments['configuration']->getFilename()));
         }
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger());
     }
     if (isset($arguments['testdoxHTMLFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory']) || isset($arguments['coveragePHP']) || isset($arguments['coverageText'])) && extension_loaded('xdebug')) {
         $codeCoverage = new PHP_CodeCoverage(NULL, $this->codeCoverageFilter);
         $codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
         if (isset($arguments['cacheTokens'])) {
             $codeCoverage->setCacheTokens($arguments['cacheTokens']);
         }
         if (isset($arguments['forceCoversAnnotation'])) {
             $codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
         }
         if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
             $codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
         }
         $result->setCodeCoverage($codeCoverage);
     }
     if (isset($arguments['jsonLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['junitLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
     }
     if ($arguments['strict']) {
         $result->strictMode(TRUE);
         $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
         $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
         $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     unset($suite);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (isset($codeCoverage)) {
         $title = '';
         if (isset($arguments['configuration'])) {
             $loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
             if (isset($loggingConfiguration['title'])) {
                 $title = $loggingConfiguration['title'];
             }
         }
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nWriting code coverage data to XML file, this may take " . 'a moment.');
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($codeCoverage, $arguments['coverageClover']);
             $this->printer->write("\n");
             unset($writer);
         }
         if (isset($arguments['reportDirectory'])) {
             $this->printer->write("\nGenerating code coverage report, this may take a moment.");
             $writer = new PHP_CodeCoverage_Report_HTML($title, $arguments['reportCharset'], $arguments['reportYUI'], $arguments['reportHighlight'], $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], ' and PHPUnit ' . PHPUnit_Runner_Version::id());
             $writer->process($codeCoverage, $arguments['reportDirectory']);
             $this->printer->write("\n");
             unset($writer);
         }
         if (isset($arguments['coveragePHP'])) {
             $this->printer->write("\nSerializing PHP_CodeCoverage object to file, this may take a moment.");
             $writer = new PHP_CodeCoverage_Report_PHP();
             $writer->process($codeCoverage, $arguments['coveragePHP']);
             $this->printer->write("\n");
             unset($writer);
         }
         if (isset($arguments['coverageText'])) {
             $this->printer->write("\nGenerating textual code coverage report, this may take a moment.");
             if ($arguments['coverageText'] == 'php://stdout') {
                 $outputStream = $this->printer;
                 $colors = (bool) $arguments['colors'];
             } else {
                 $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
                 $colors = FALSE;
             }
             $writer = new PHP_CodeCoverage_Report_Text($outputStream, $title, $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles']);
             $writer->process($codeCoverage, $colors);
             $this->printer->write("\n");
         }
     }
     return $result;
 }
Ejemplo n.º 6
0
 protected function printText()
 {
     $writer = new \PHP_CodeCoverage_Report_Text($this->settings['low_limit'], $this->settings['high_limit'], $this->settings['show_uncovered'], false);
     file_put_contents($this->absolutePath($this->options['coverage-text']), $writer->process(self::$coverage, false));
 }
Ejemplo n.º 7
0
 /**
  * @param  PHPUnit_Framework_Test $suite
  * @param  array                  $arguments
  *
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     if (isset($arguments['bootstrap'])) {
         $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
     }
     if ($arguments['backupGlobals'] === false) {
         $suite->setBackupGlobals(false);
     }
     if ($arguments['backupStaticAttributes'] === true) {
         $suite->setBackupStaticAttributes(true);
     }
     if (is_integer($arguments['repeat'])) {
         $test = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
         $suite = new PHPUnit_Framework_TestSuite();
         $suite->addTest($test);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(false);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = false;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = false;
     }
     if ($arguments['stopOnError']) {
         $result->stopOnError(true);
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(true);
     }
     if ($arguments['stopOnIncomplete']) {
         $result->stopOnIncomplete(true);
     }
     if ($arguments['stopOnSkipped']) {
         $result->stopOnSkipped(true);
     }
     if ($this->printer === null) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $this->printer = new PHPUnit_TextUI_ResultPrinter(null, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
         self::$versionStringPrinted = true;
         if (isset($arguments['configuration'])) {
             $this->printer->write(sprintf("Configuration read from %s\n\n", $arguments['configuration']->getFilename()));
         }
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $result->addListener(new PHPUnit_Util_DeprecatedFeature_Logger());
     }
     if (isset($arguments['testdoxHTMLFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     $codeCoverageReports = 0;
     if (extension_loaded('xdebug')) {
         if (isset($arguments['coverageClover'])) {
             $codeCoverageReports++;
         }
         if (isset($arguments['reportDirectory'])) {
             $codeCoverageReports++;
         }
         if (isset($arguments['coveragePHP'])) {
             $codeCoverageReports++;
         }
         if (isset($arguments['coverageText'])) {
             $codeCoverageReports++;
         }
     }
     if ($codeCoverageReports > 0) {
         $codeCoverage = new PHP_CodeCoverage(null, $this->codeCoverageFilter);
         $codeCoverage->setAddUncoveredFilesFromWhitelist($arguments['addUncoveredFilesFromWhitelist']);
         $codeCoverage->setProcessUncoveredFilesFromWhitelist($arguments['processUncoveredFilesFromWhitelist']);
         if (isset($arguments['forceCoversAnnotation'])) {
             $codeCoverage->setForceCoversAnnotation($arguments['forceCoversAnnotation']);
         }
         if (isset($arguments['mapTestClassNameToCoveredClassName'])) {
             $codeCoverage->setMapTestClassNameToCoveredClassName($arguments['mapTestClassNameToCoveredClassName']);
         }
         $result->setCodeCoverage($codeCoverage);
     }
     if ($codeCoverageReports > 1) {
         if (isset($arguments['cacheTokens'])) {
             $codeCoverage->setCacheTokens($arguments['cacheTokens']);
         }
     }
     if (isset($arguments['jsonLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['junitLogfile'])) {
         $result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
     }
     if ($arguments['strict']) {
         $result->strictMode(true);
         $result->setTimeoutForSmallTests($arguments['timeoutForSmallTests']);
         $result->setTimeoutForMediumTests($arguments['timeoutForMediumTests']);
         $result->setTimeoutForLargeTests($arguments['timeoutForLargeTests']);
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     unset($suite);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (isset($codeCoverage)) {
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nGenerating code coverage report in Clover XML format ...");
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($codeCoverage, $arguments['coverageClover']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['reportDirectory'])) {
             $this->printer->write("\nGenerating code coverage report in HTML format ...");
             $writer = new PHP_CodeCoverage_Report_HTML($arguments['reportCharset'], $arguments['reportHighlight'], $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], sprintf(' and <a href="http://phpunit.de/">PHPUnit %s</a>', PHPUnit_Runner_Version::id()));
             $writer->process($codeCoverage, $arguments['reportDirectory']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coveragePHP'])) {
             $this->printer->write("\nGenerating code coverage report in PHP format ...");
             $writer = new PHP_CodeCoverage_Report_PHP();
             $writer->process($codeCoverage, $arguments['coveragePHP']);
             $this->printer->write(" done\n");
             unset($writer);
         }
         if (isset($arguments['coverageText'])) {
             if ($arguments['coverageText'] == 'php://stdout') {
                 $outputStream = $this->printer;
                 $colors = (bool) $arguments['colors'];
             } else {
                 $outputStream = new PHPUnit_Util_Printer($arguments['coverageText']);
                 $colors = false;
             }
             $writer = new PHP_CodeCoverage_Report_Text($outputStream, $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound'], $arguments['coverageTextShowUncoveredFiles']);
             $writer->process($codeCoverage, $colors);
         }
     }
     return $result;
 }
Ejemplo n.º 8
0
 /**
  * @covers PHP_CodeCoverage_Report_Text
  */
 public function testTextForClassWithAnonymousFunction()
 {
     $text = new PHP_CodeCoverage_Report_Text(50, 90, false, false);
     $this->assertStringMatchesFormatFile(TEST_FILES_PATH . 'class-with-anonymous-function-text.txt', str_replace(PHP_EOL, "\n", $text->process($this->getCoverageForClassWithAnonymousFunction())));
 }
Ejemplo n.º 9
0
 private function reportText()
 {
     /* @var \PHP_CodeCoverage_Report_Text $report */
     $this->logger->addCommon('Processing text output... please wait!');
     $options = $this->options;
     $report = new \PHP_CodeCoverage_Report_Text($options['lower_upper_bound'], $options['high_lower_bound'], $options['show_uncovered_files'], $options['show_only_summary']);
     /* @var \Symfony\Component\Console\Output\ConsoleOutputInterface $writer */
     $writer = $this->container->get('ui.output');
     $output = $report->process($this->coverage, $writer->getFormatter()->isDecorated());
     $writer->writeln($output);
 }
Ejemplo n.º 10
0
 protected function printText($printer)
 {
     $writer = new \PHP_CodeCoverage_Report_Text($printer, $this->settings['low_limit'], $this->settings['high_limit'], $this->settings['show_uncovered']);
     $writer->process($this->coverage, $this->options['colors']);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function process(\PHP_CodeCoverage $coverage)
 {
     return $this->report->process($coverage, $this->options['showColors']);
 }
Ejemplo n.º 12
0
 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'php', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'text', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'add-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('', 'process-uncovered', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $html = $input->getOption('html')->value;
     $php = $input->getOption('php')->value;
     $text = $input->getOption('text')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $addUncovered = $input->getOption('add-uncovered')->value;
     $processUncovered = $input->getOption('process-uncovered')->value;
     $merge = $input->getOption('merge')->value;
     if (count($arguments) == 1) {
         self::printVersionString();
         $coverage = new PHP_CodeCoverage();
         $filter = $coverage->filter();
         if (empty($whitelist)) {
             $c = new ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             $coverage->setAddUncoveredFilesFromWhitelist($addUncovered);
             $coverage->setProcessUncoveredFilesFromWhitelist($processUncovered);
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $finder = new Symfony\Component\Finder\Finder();
             $finder->in($arguments[0])->name('*.cov');
             foreach ($finder as $file) {
                 $coverage->merge(unserialize(file_get_contents($file->getRealpath())));
             }
         }
         if ($clover) {
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
         }
         if ($html) {
             $writer = new PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
         }
         if ($php) {
             $writer = new PHP_CodeCoverage_Report_PHP();
             $writer->process($coverage, $php);
         }
         if ($text) {
             $writer = new PHP_CodeCoverage_Report_Text();
             $writer->process($coverage, $text);
         }
     } else {
         self::showHelp();
         exit(1);
     }
 }
Ejemplo n.º 13
0
 private function handleReports(\PHP_CodeCoverage $coverage)
 {
     if ($this->clover) {
         $this->log("Generating code coverage report in Clover XML format ...");
         $writer = new \PHP_CodeCoverage_Report_Clover();
         $writer->process($coverage, $this->clover);
     }
     if ($this->crap4j) {
         $this->log("Generating code coverage report in Crap4J XML format...");
         $writer = new \PHP_CodeCoverage_Report_Crap4j();
         $writer->process($coverage, $this->crap4j);
     }
     if ($this->html) {
         $this->log("Generating code coverage report in HTML format ...");
         $writer = new \PHP_CodeCoverage_Report_HTML();
         $writer->process($coverage, $this->html);
     }
     if ($this->php) {
         $this->log("Generating code coverage report in PHP format ...");
         $writer = new \PHP_CodeCoverage_Report_PHP();
         $writer->process($coverage, $this->php);
     }
     if ($this->text) {
         $writer = new \PHP_CodeCoverage_Report_Text(50, 90, false, false);
         $writer->process($coverage, $this->text);
     }
 }