本文整理汇总了PHP中PHPUnit_TextUI_ResultPrinter类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_ResultPrinter类的具体用法?PHP PHPUnit_TextUI_ResultPrinter怎么用?PHP PHPUnit_TextUI_ResultPrinter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_TextUI_ResultPrinter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例3: pause
/**
* @param boolean $wait
*/
protected function pause($wait)
{
if (!$wait) {
return;
}
if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
$this->printer->printWaitPrompt();
}
fgets(STDIN);
}
示例4: startTestSuite
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
if ($this->maxLength == 0) {
$iterator = new RecursiveIteratorIterator(new PHPUnit_Util_TestSuiteIterator($suite), RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
if ($item instanceof PHPUnit_Framework_TestSuite) {
$name = $item->getName();
if ($name == '') {
$name = '[No name given]';
} else {
$name = explode('::', $name);
$name = array_pop($name);
}
$this->maxLength = max($this->maxLength, strlen($name));
$item->setName($name);
}
}
}
if ($this->depth > 0) {
parent::write("\n");
}
if ($this->depth == 1) {
parent::write("\n");
}
parent::write(str_pad(str_repeat(' ', $this->depth++) . $suite->getName() . ': ', 40, ' ', STR_PAD_RIGHT));
}
示例5: printFooter
/**
* Just add to the output the seed used to randomize the test suite.
*
* @param PHPUnit_Framework_TestResult $result
*/
protected function printFooter(\PHPUnit_Framework_TestResult $result)
{
parent::printFooter($result);
$this->writeNewLine();
$this->write("Randomized with seed: {$this->seed}");
$this->writeNewLine();
}
示例6: endTest
/**
* A test ended.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
parent::endTest($test, $time);
if ($test instanceof \Pagosoft\PSpec\Test) {
$this->numAssertions += $test->getNumAssertions();
}
}
示例7: writeProgress
/**
* {@inheritdoc}
*/
protected function writeProgress($progress)
{
if ($progress == '.') {
$progress = $this->fab->paintChar('*');
}
parent::writeProgress($progress);
}
示例8: endTestSuite
/**
* @param PHPUnit_Framework_TestSuite $suite
* @since Method available since Release 2.7.0
*/
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$oldVerbose = $this->verbose;
$this->verbose = false;
parent::endTestSuite($suite);
$this->verbose = $oldVerbose;
}
示例9: pause
/**
* @param boolean $wait
* @access protected
*/
protected function pause($wait)
{
if (!$wait) {
return;
}
$this->fPrinter->printWaitPrompt();
fgets(STDIN);
}
示例10: printDefectTrace
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
{
global $CFG;
parent::printDefectTrace($defect);
$failedTest = $defect->failedTest();
$testName = get_class($failedTest);
$exception = $defect->thrownException();
$trace = $exception->getTrace();
if (class_exists('ReflectionClass')) {
$reflection = new ReflectionClass($testName);
$file = $reflection->getFileName();
} else {
$file = false;
$dirroot = realpath($CFG->dirroot) . DIRECTORY_SEPARATOR;
$classpath = realpath("{$CFG->dirroot}/lib/phpunit/classes") . DIRECTORY_SEPARATOR;
foreach ($trace as $item) {
if (strpos($item['file'], $dirroot) === 0 and strpos($item['file'], $classpath) !== 0) {
if ($content = file_get_contents($item['file'])) {
if (preg_match('/class\\s+' . $testName . '\\s+extends/', $content)) {
$file = $item['file'];
break;
}
}
}
}
}
if ($file === false) {
return;
}
$cwd = getcwd();
if (strpos($file, $cwd) === 0) {
$file = substr($file, strlen($cwd) + 1);
}
$executable = null;
if (isset($_SERVER['argv'][0])) {
if (preg_match('/phpunit(\\.bat|\\.cmd)?$/', $_SERVER['argv'][0])) {
$executable = $_SERVER['argv'][0];
for ($i = 1; $i < count($_SERVER['argv']); $i++) {
if (!isset($_SERVER['argv'][$i])) {
break;
}
if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug', '--strict'))) {
$executable .= ' ' . $_SERVER['argv'][$i];
}
}
}
}
if (!$executable) {
$executable = 'phpunit';
if (testing_is_cygwin()) {
$file = str_replace('\\', '/', $file);
if (!testing_is_mingw()) {
$executable = 'phpunit.bat';
}
}
}
$this->write("\nTo re-run:\n {$executable} {$testName} {$file}\n");
}
示例11: printFooter
protected function printFooter(PHPUnit_Framework_TestResult $result)
{
$this->write('<div class="stats">');
parent::printFooter($result);
$this->write('</div>');
$this->write('<div class="resourceUsage">');
$this->write(PHP_Timer::resourceUsage());
$this->write('</div>');
}
示例12: __construct
public function __construct($backtrace, $colors = false)
{
parent::__construct(null, false, $colors);
$this->backtrace = '';
foreach ($backtrace as $trace) {
if (isset($trace['file']) && isset($trace['line'])) {
$this->backtrace .= $trace['file'] . ':' . $trace['line'] . "\n";
}
}
}
示例13: 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;
}
示例14: write
/**
* @param string $buffer
* @since Method available since Release 3.1.0
*/
protected function write($buffer)
{
if (PHP_SAPI != 'cli') {
$buffer = htmlspecialchars($buffer);
}
if ($this->printer !== null) {
$this->printer->write($buffer);
} else {
print $buffer;
}
}
示例15: printDefectTrace
protected function printDefectTrace(\PHPUnit_Framework_TestFailure $defect)
{
$e = $defect->thrownException();
if (!$e instanceof \atk4\core\PHPUnit_AgileExceptionWrapper) {
return parent::printDefectTrace($defect);
}
$this->write((string) $e);
$p = $e->getPrevious();
if ($p instanceof \atk4\core\Exception or $p instanceof \atk4\dsql\Exception) {
$this->write($p->getColorfulText());
}
}