本文整理汇总了PHP中PHPUnit_TextUI_ResultPrinter::printDefectTrace方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_ResultPrinter::printDefectTrace方法的具体用法?PHP PHPUnit_TextUI_ResultPrinter::printDefectTrace怎么用?PHP PHPUnit_TextUI_ResultPrinter::printDefectTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_TextUI_ResultPrinter
的用法示例。
在下文中一共展示了PHPUnit_TextUI_ResultPrinter::printDefectTrace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
示例2: 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());
}
}
示例3: 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);
$file = testing_cli_fix_directory_separator($file);
}
$pathprefix = testing_cli_argument_path('/');
if ($pathprefix) {
$pathprefix .= DIRECTORY_SEPARATOR;
}
// There is only vendor/bin/phpunit executable. There is no .cmd or .bat files.
$executable = $pathprefix . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'phpunit';
$executable = testing_cli_fix_directory_separator($executable);
// Add server arguments to the rerun if passed.
if (isset($_SERVER['argv'][0])) {
if (preg_match('/phpunit(\\.bat|\\.cmd)?$/', $_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'))) {
$executable .= ' ' . $_SERVER['argv'][$i];
} else {
if (in_array($_SERVER['argv'][$i], array('-c', '--config'))) {
$executable .= ' ' . $_SERVER['argv'][$i] . ' ' . $_SERVER['argv'][++$i];
} else {
if (strpos($_SERVER['argv'][$i], '--config') === 0) {
$executable .= ' ' . $_SERVER['argv'][$i];
}
}
}
}
}
}
$this->write("\nTo re-run:\n {$executable} {$testName} {$file}\n");
}
示例4: printDefectTrace
/**
* @param PHPUnit_Framework_TestFailure $defect
*/
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
{
if (version_compare(PHPUnit_Runner_Version::id(), '3.6.0', '<')) {
parent::printDefectTrace($defect);
} else {
// In PHPUnit 3.6, we need to filter the test harness files from the
// stack trace ourselves. There is no way to access and customize the
// built-in filter, as there used to be in PHP 3.5.
//
// (Actually, the built-in filter can be manipulated - see StackOverflow
// http://goo.gl/HP2el. But it doesn't work with PHP 5.2.)
ob_start();
parent::printDefectTrace($defect);
$trace = ob_get_clean();
$lines = explode("\n", $trace);
$filtered_stacktrace = array();
foreach ($lines as $line) {
$include = true;
foreach ($this->blacklist as $blacklisted) {
$include = stripos($line, $blacklisted) !== 0;
if (!$include) {
break;
}
}
if ($include) {
$filtered_stacktrace[] = $line;
}
}
$this->write(implode("\n", $filtered_stacktrace));
}
}
示例5: 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);
}
$this->write("\nTo re-run:\n phpunit {$testName} {$file}\n");
}