本文整理汇总了PHP中PHPUnit_TextUI_ResultPrinter::printResult方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_ResultPrinter::printResult方法的具体用法?PHP PHPUnit_TextUI_ResultPrinter::printResult怎么用?PHP PHPUnit_TextUI_ResultPrinter::printResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_TextUI_ResultPrinter
的用法示例。
在下文中一共展示了PHPUnit_TextUI_ResultPrinter::printResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printResult
/**
* @param \PHPUnit_Framework_TestResult $result
*/
public function printResult(\PHPUnit_Framework_TestResult $result)
{
if ($this->runner->shouldNotify()) {
ob_start();
}
$testDox = trim(TestDox::get(spl_object_hash($result)));
if (strlen($testDox)) {
$this->write(PHP_EOL . PHP_EOL . $testDox);
}
parent::printResult($result);
if ($this->runner->shouldNotify()) {
$output = ob_get_contents();
ob_end_clean();
echo $output;
if ($result->failureCount() + $result->errorCount() + $result->skippedCount() + $result->notImplementedCount() == 0) {
$notificationResult = Notification::RESULT_PASSED;
} else {
$notificationResult = Notification::RESULT_FAILED;
}
if (preg_match('/^(?:\\x1b\\[30;42m\\x1b\\[2K)?(OK .+)/m', $output, $matches)) {
$notificationMessage = $matches[1];
} elseif (preg_match('/^(?:\\x1b\\[37;41m\\x1b\\[2K)?(FAILURES!)\\s^(?:\\x1b\\[0m\\x1b\\[37;41m\\x1b\\[2K)?(.+)/m', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/^(?:\\x1b\\[30;43m\\x1b\\[2K)?(OK, but incomplete or skipped tests!)\\s^(?:\\x1b\\[0m\\x1b\\[30;43m\\x1b\\[2K)?(.+)/m', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/^(?:\\x1b\\[30;43m\\x1b\\[2K)?(No tests executed!)/m', $output, $matches)) {
$notificationMessage = $matches[1];
}
$this->notification = new Notification($notificationResult, $notificationMessage);
}
}
示例2: printResult
/**
* @param \PHPUnit_Framework_TestResult $result
*/
public function printResult(\PHPUnit_Framework_TestResult $result)
{
if ($this->runner->shouldNotify()) {
ob_start();
}
$testDox = trim(TestDox::get(spl_object_hash($result)));
if (strlen($testDox)) {
$this->write(PHP_EOL . PHP_EOL . $testDox);
}
parent::printResult($result);
if ($this->runner->shouldNotify()) {
$output = ob_get_contents();
ob_end_clean();
echo $output;
if ($result->failureCount() + $result->errorCount() + $result->skippedCount() + $result->notImplementedCount() == 0) {
$notificationResult = Notification::RESULT_PASSED;
} else {
$notificationResult = Notification::RESULT_FAILED;
}
$output = $this->removeAnsiEscapeCodesForColors($output);
if (preg_match('/(OK \\(\\d+ tests?, \\d+ assertions?\\))/', $output, $matches)) {
$notificationMessage = $matches[1];
} elseif (preg_match('/(FAILURES!)\\s+(.*)/', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/(OK, but incomplete,.*!)\\s+(.*)/', $output, $matches)) {
$notificationMessage = $matches[1] . PHP_EOL . $matches[2];
} elseif (preg_match('/(No tests executed!)/', $output, $matches)) {
$notificationMessage = $matches[1];
} else {
$notificationMessage = '';
}
$this->notification = new Notification($notificationResult, $notificationMessage);
}
}
示例3: printResult
/**
* @param PHPUnit_Framework_TestResult $result
*/
public function printResult(PHPUnit_Framework_TestResult $result)
{
$testDox = trim(Stagehand_TestRunner_Runner_PHPUnitRunner_TestDox::get(spl_object_hash($result)));
if (strlen($testDox)) {
$this->write("\n\n" . $testDox);
}
parent::printResult($result);
}
示例4: getResultsOutput
/**
* @param \PHPUnit_Framework_TestResult[] $results
*/
public function getResultsOutput(array $results, $output_stream = null)
{
assert(is_array($results));
assert(!empty($results));
$Printer = new \PHPUnit_TextUI_ResultPrinter($output_stream);
foreach ($results as $Result) {
$Printer->printResult($Result);
}
}
示例5: doRun
/**
* @param PHPUnit_Framework_Test $suite
* @param array $parameters
* @return PHPUnit_Framework_TestResult
* @access public
*/
public function doRun(PHPUnit_Framework_Test $suite, array $parameters = array())
{
$parameters['repeat'] = isset($parameters['repeat']) ? $parameters['repeat'] : FALSE;
$parameters['filter'] = isset($parameters['filter']) ? $parameters['filter'] : FALSE;
$parameters['verbose'] = isset($parameters['verbose']) ? $parameters['verbose'] : FALSE;
if (is_integer($parameters['repeat'])) {
$suite = new PHPUnit_Extensions_RepeatedTest($suite, $parameters['repeat']);
}
if (isset($parameters['reportDirectory'])) {
$parameters['reportDirectory'] = $this->getDirectory($parameters['reportDirectory']);
}
$result = $this->createTestResult();
if ($this->printer === NULL) {
$this->printer = $parameters['xml'] ? new CopixTestXMLPrinter(NULL, $parameters['verbose']) : new CopixTestPrinter(NULL, $parameters['verbose']);
}
$result->addListener($this->printer);
if (isset($parameters['testdoxHTMLFile'])) {
$result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('HTML', $parameters['testdoxHTMLFile']));
}
if (isset($parameters['testdoxTextFile'])) {
$result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('Text', $parameters['testdoxTextFile']));
}
if (isset($parameters['graphvizLogfile'])) {
if (class_exists('Image_GraphViz', FALSE) && class_exists('PHPUnit_Util_Log_GraphViz', FALSE)) {
$result->addListener(new PHPUnit_Util_Log_GraphViz($parameters['graphvizLogfile']));
}
}
if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
if (class_exists('Image_GraphViz', FALSE) && class_exists('PHPUnit_Util_Report_GraphViz', FALSE)) {
$result->addListener(new PHPUnit_Util_Report_GraphViz($parameters['reportDirectory']));
}
$result->collectCodeCoverageInformation(TRUE);
}
if (isset($parameters['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($parameters['jsonLogfile']));
}
if (isset($parameters['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($parameters['tapLogfile']));
}
if (isset($parameters['xmlLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_XML($parameters['xmlLogfile']));
}
$suite->run($result, $parameters['filter']);
$result->flushListeners();
if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
$this->printer->codeCoverage($parameters['reportDirectory']);
PHPUnit_Util_Report::render($result, $parameters['reportDirectory']);
} else {
$this->printer->codeCoverage(false);
}
if ($this->printer) {
$this->printer->printResult($result);
}
return $result;
}
示例6: doRun
/**
* Runs a test suite.
*
* @param PHPUnit_Framework_Test $suite
* @param optional boolean $wait
* @return PHPUnit_Framework_TestResult
* @access public
*/
public function doRun(PHPUnit_Framework_Test $suite, $wait = false)
{
printf("PHPUnit %s by Sebastian Bergmann.\n\n", PHPUnit_Framework_Version);
$result = new PHPUnit_Framework_TestResult();
$result->addListener($this->fPrinter);
$timer = new Benchmark_Timer();
$timer->start();
$suite->run($result);
$timer->stop();
$this->pause($wait);
$this->fPrinter->printResult($result, $timer->timeElapsed());
return $result;
}
示例7: main
function main()
{
function cleanup()
{
global $wpdb;
// we need to ensure that we switch off this database
$wpdb->select(null);
// drop our test database
// XXX: why cant we use $wpdb->query ?
mysql_query(sprintf('DROP DATABASE `%s`', DISQUS_TEST_DATABASE)) or die(mysql_error());
}
global $wpdb;
// $this->query(sprintf('DROP DATABASE IF EXISTS `%s`', DISQUS_TEST_DATABASE));
// check existance of test db
$exists = $wpdb->get_var($wpdb->prepare('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', DISQUS_TEST_DATABASE));
if (!empty($exists)) {
printf("Test database '%s' already exists. Continuing will drop this database and all data!\nContinue? [y/n]\n", $exists);
$handle = fopen("php://stdin", "r");
$line = strtolower(trim(fgets($handle)));
if ($line != 'yes' && $line != 'y') {
echo "ABORTING!\n";
exit;
}
}
// setup database
$wpdb->query(sprintf('CREATE DATABASE `%s`', DISQUS_TEST_DATABASE));
$wpdb->select(DISQUS_TEST_DATABASE);
// $fp = fopen('initial.sql', 'r');
// $buffer = '';
// while (($line = fgets($fp)) !== false) {
// $buffer .= trim($line);
// if (strpos($line, ';')) {
// if (!empty($buffer)) {
// $this->query($buffer);
// }
// $buffer = '';
// }
// }
//
try {
$suite = new PHPUnit_Framework_TestSuite('DisqusPluginTest');
$result = $suite->run();
require_once 'PHPUnit/TextUI/ResultPrinter.php';
$printer = new PHPUnit_TextUI_ResultPrinter();
$printer->printResult($result);
cleanup();
} catch (Exception $ex) {
cleanup();
throw $ex;
}
}
示例8: printResult
/**
* {@inheritdoc}
*/
public function printResult(\PHPUnit_Framework_TestResult $result)
{
parent::printResult($result);
if ($this->browserOutputFile) {
$contents = file_get_contents($this->browserOutputFile);
if ($contents) {
$this->writeNewLine();
$this->writeWithColor('bg-yellow, fg-black', 'HTML output was generated');
$this->write($contents);
}
// No need to keep the file around any more.
unlink($this->browserOutputFile);
}
}
示例9: printResult
public function printResult(\PHPUnit_Framework_TestResult $result)
{
// Standard output
parent::printResult($result);
// Capture footer and send to Growl.
$this->capture = true;
parent::printFooter($result);
$this->capture = false;
if (strstr($this->color, 'red')) {
$type = "RED";
} elseif (strstr($this->color, 'green')) {
$type = "GREEN";
} else {
$type = "YELLOW";
}
try {
$this->sendNotify($this->buffer, $type);
} catch (\Exception $e) {
$this->write("[growlprinter] Could not send notification.\n" . $e->getMessage());
}
}
示例10: doRun
/**
* @param PHPUnit_Framework_Test $suite
* @param array $parameters
* @return PHPUnit_Framework_TestResult
* @access public
*/
public function doRun(PHPUnit_Framework_Test $suite, array $parameters = array())
{
$parameters['filter'] = isset($parameters['filter']) ? $parameters['filter'] : FALSE;
$parameters['stopOnFailure'] = isset($parameters['stopOnFailure']) ? $parameters['stopOnFailure'] : FALSE;
$parameters['repeat'] = isset($parameters['repeat']) ? $parameters['repeat'] : FALSE;
$parameters['verbose'] = isset($parameters['verbose']) ? $parameters['verbose'] : FALSE;
$parameters['wait'] = isset($parameters['wait']) ? $parameters['wait'] : FALSE;
if (is_integer($parameters['repeat'])) {
$suite = new PHPUnit_Extensions_RepeatedTest($suite, $parameters['repeat']);
}
if (isset($parameters['reportDirectory'])) {
$parameters['reportDirectory'] = $this->getDirectory($parameters['reportDirectory']);
}
$result = $this->createTestResult();
if ($parameters['stopOnFailure']) {
$result->stopOnFailure(TRUE);
}
if ($this->printer === NULL) {
if (isset($parameters['printer']) && $parameters['printer'] instanceof PHPUnit_Util_Printer) {
$this->printer = $parameters['printer'];
} else {
$this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $parameters['verbose']);
}
}
$this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
$result->addListener($this->printer);
if (isset($parameters['testdoxHTMLFile'])) {
$result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('HTML', $parameters['testdoxHTMLFile']));
}
if (isset($parameters['testdoxTextFile'])) {
$result->addListener(PHPUnit_Util_TestDox_ResultPrinter::factory('Text', $parameters['testdoxTextFile']));
}
if (isset($parameters['graphvizLogfile'])) {
if (class_exists('Image_GraphViz', FALSE)) {
$result->addListener(new PHPUnit_Util_Log_GraphViz($parameters['graphvizLogfile']));
}
}
if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
if (class_exists('Image_GraphViz', FALSE)) {
$result->addListener(new PHPUnit_Util_Report_GraphViz($parameters['reportDirectory']));
}
$result->addListener(new PHPUnit_TextUI_ResultPrinter($parameters['reportDirectory'] . '/logfile.txt', TRUE));
$result->addListener(new PHPUnit_Util_Log_XML($parameters['reportDirectory'] . '/logfile.xml'));
$result->addListener(new PHPUnit_Util_Log_TAP($parameters['reportDirectory'] . '/logfile.tap'));
$result->collectCodeCoverageInformation(TRUE);
}
if (isset($parameters['jsonLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_JSON($parameters['jsonLogfile']));
}
if (isset($parameters['tapLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_TAP($parameters['tapLogfile']));
}
if (isset($parameters['xmlLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_XML($parameters['xmlLogfile']));
}
if (isset($parameters['testDatabaseDSN']) && isset($parameters['testDatabaseLogRevision']) && extension_loaded('pdo')) {
$writeToTestDatabase = TRUE;
} else {
$writeToTestDatabase = FALSE;
}
if ($writeToTestDatabase) {
$dbh = new PDO($parameters['testDatabaseDSN']);
$dbListener = PHPUnit_Util_Log_Database::getInstance($dbh, $parameters['testDatabaseLogRevision'], isset($parameters['testDatabaseLogInfo']) ? $parameters['testDatabaseLogInfo'] : '');
$result->addListener($dbListener);
$result->collectCodeCoverageInformation(TRUE);
}
$suite->run($result, $parameters['filter']);
$result->flushListeners();
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$this->printer->printResult($result);
}
if ($writeToTestDatabase && extension_loaded('xdebug')) {
$this->printer->write("\nStoring code coverage data in database, this may take a moment.");
$testDb = new PHPUnit_Util_Database($dbh);
$testDb->storeCodeCoverage($result, $parameters['testDatabaseLogRevision']);
$this->printer->write("\n");
}
if (isset($parameters['reportDirectory']) && extension_loaded('xdebug')) {
$this->printer->write("\nGenerating report, this may take a moment.");
PHPUnit_Util_Report::render($result, $parameters['reportDirectory']);
$this->printer->write("\n");
}
$this->pause($parameters['wait']);
return $result;
}
示例11: doRun
//.........这里部分代码省略.........
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;
}
示例12: doRun
/**
* @param PHPUnit_Framework_Test $suite
* @param array $arguments
* @return PHPUnit_Framework_TestResult
* @access public
*/
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
{
$this->handleConfiguration($arguments);
if (is_integer($arguments['repeat'])) {
$suite = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups']);
}
$result = $this->createTestResult();
if ($arguments['stopOnFailure']) {
$result->stopOnFailure(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']);
}
}
$this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\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']));
}
if (isset($arguments['graphvizLogfile'])) {
if (class_exists('Image_GraphViz', FALSE)) {
$result->addListener(new PHPUnit_Util_Log_GraphViz($arguments['graphvizLogfile']));
}
}
if ((isset($arguments['coverageXML']) || isset($arguments['metricsXML']) || isset($arguments['pmdXML'])) && extension_loaded('xdebug')) {
$result->collectCodeCoverageInformation(TRUE);
}
if (isset($arguments['reportDirectory']) && extension_loaded('xdebug')) {
$result->collectCodeCoverageInformation(TRUE);
}
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['xmlLogfile'])) {
$result->addListener(new PHPUnit_Util_Log_XML($arguments['xmlLogfile'], $arguments['logIncompleteSkipped']));
}
if (isset($arguments['testDatabaseDSN']) && isset($arguments['testDatabaseLogRevision']) && extension_loaded('pdo')) {
$writeToTestDatabase = TRUE;
} else {
$writeToTestDatabase = FALSE;
}
if ($writeToTestDatabase) {
$dbh = PHPUnit_Util_PDO::factory($arguments['testDatabaseDSN']);
$dbListener = PHPUnit_Util_Log_Database::getInstance($dbh, $arguments['testDatabaseLogRevision'], isset($arguments['testDatabaseLogInfo']) ? $arguments['testDatabaseLogInfo'] : '');
$result->addListener($dbListener);
$result->collectCodeCoverageInformation(TRUE);
}
$suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups']);
$result->flushListeners();
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$this->printer->printResult($result);
}
if (isset($arguments['coverageXML']) && extension_loaded('tokenizer') && extension_loaded('xdebug')) {
$this->printer->write("\nWriting code coverage data to XML file, this may take a moment.");
$writer = new PHPUnit_Util_Log_CodeCoverage_XML($arguments['coverageXML']);
$writer->process($result);
$this->printer->write("\n");
}
if ($writeToTestDatabase && extension_loaded('tokenizer') && extension_loaded('xdebug')) {
$this->printer->write("\nStoring code coverage and software metrics data in database.\nThis may take a moment.");
$testDb = new PHPUnit_Util_Log_CodeCoverage_Database($dbh);
$testDb->storeCodeCoverage($result, $dbListener->getRunId(), $arguments['testDatabaseLogRevision'], $arguments['testDatabasePrefix']);
$this->printer->write("\n");
}
if (isset($arguments['metricsXML']) && extension_loaded('tokenizer') && extension_loaded('xdebug')) {
$this->printer->write("\nWriting metrics report XML file, this may take a moment.");
$writer = new PHPUnit_Util_Log_Metrics($arguments['metricsXML']);
$writer->process($result);
$this->printer->write("\n");
}
if (isset($arguments['pmdXML']) && extension_loaded('tokenizer') && extension_loaded('xdebug')) {
$writer = new PHPUnit_Util_Log_PMD($arguments['pmdXML'], $arguments['pmd']);
$this->printer->write("\nWriting violations report XML file, this may take a moment.");
$writer->process($result);
$writer = new PHPUnit_Util_Log_CPD(str_replace('.xml', '-cpd.xml', $arguments['pmdXML']));
$writer->process($result, $arguments['cpdMinLines'], $arguments['cpdMinMatches']);
$this->printer->write("\n");
}
if (isset($arguments['reportDirectory']) && extension_loaded('xdebug')) {
$this->printer->write("\nGenerating code coverage report, this may take a moment.");
PHPUnit_Util_Report::render($result, $arguments['reportDirectory'], $arguments['reportCharset'], $arguments['reportYUI'], $arguments['reportHighlight'], $arguments['reportLowUpperBound'], $arguments['reportHighLowerBound']);
$this->printer->write("\n");
//.........这里部分代码省略.........
示例13: doRun
//.........这里部分代码省略.........
}
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) {
示例14: doRun
/**
* @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'])) {
$bootstrap = PHPUnit_Util_Fileloader::load($arguments['bootstrap']);
if ($bootstrap) {
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = $bootstrap;
}
}
if ($arguments['backupGlobals'] === FALSE) {
$suite->setBackupGlobals(FALSE);
}
if ($arguments['backupStaticAttributes'] === FALSE) {
$suite->setBackupStaticAttributes(FALSE);
}
$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['stopOnFailure']) {
$result->stopOnFailure(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");
}
foreach ($arguments['listeners'] as $listener) {
$result->addListener($listener);
}
$result->addListener($this->printer);
if (isset($arguments['storyHTMLFile'])) {
require_once 'PHPUnit/Extensions/Story/ResultPrinter/HTML.php';
$result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_HTML($arguments['storyHTMLFile']));
}
if (isset($arguments['storyTextFile'])) {
require_once 'PHPUnit/Extensions/Story/ResultPrinter/Text.php';
$result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_Text($arguments['storyTextFile']));
}
if (isset($arguments['testdoxHTMLFile'])) {
require_once 'PHPUnit/Util/TestDox/ResultPrinter/HTML.php';
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
}
if (isset($arguments['testdoxTextFile'])) {
require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
$result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
}
if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory'])) && extension_loaded('xdebug')) {
$result->collectCodeCoverageInformation(TRUE);
}
if (isset($arguments['logDbus'])) {
require_once 'PHPUnit/Util/Log/DBUS.php';
$result->addListener(new PHPUnit_Util_Log_DBUS());
}
if (isset($arguments['jsonLogfile'])) {
require_once 'PHPUnit/Util/Log/JSON.php';
$result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
}
if (isset($arguments['tapLogfile'])) {
require_once 'PHPUnit/Util/Log/TAP.php';
$result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
}
if (isset($arguments['junitLogfile'])) {
require_once 'PHPUnit/Util/Log/JUnit.php';
$result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
}
$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 (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
if (isset($arguments['coverageClover'])) {
$this->printer->write("\nWriting code coverage data to XML file, this may take " . 'a moment.');
require_once 'PHP/CodeCoverage/Report/Clover.php';
$writer = new PHP_CodeCoverage_Report_Clover();
$writer->process($result->getCodeCoverage(), $arguments['coverageClover']);
$this->printer->write("\n");
unset($writer);
}
if (isset($arguments['reportDirectory'])) {
$this->printer->write("\nGenerating code coverage report, this may take a moment.");
$title = '';
//.........这里部分代码省略.........
示例15: doRun
//.........这里部分代码省略.........
}
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;
}