本文整理汇总了PHP中PHPUnit_Framework_ComparisonFailure::hasDiff方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_ComparisonFailure::hasDiff方法的具体用法?PHP PHPUnit_Framework_ComparisonFailure::hasDiff怎么用?PHP PHPUnit_Framework_ComparisonFailure::hasDiff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_ComparisonFailure
的用法示例。
在下文中一共展示了PHPUnit_Framework_ComparisonFailure::hasDiff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printDefectTrace
/**
* @param PHPUnit_Framework_TestFailure $defect
* @access protected
*/
protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
{
$e = $defect->thrownException();
if ($e instanceof PHPUnit_Framework_SelfDescribing) {
$buffer = $e->toString();
if (!empty($buffer)) {
$buffer .= "\n";
}
if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
$comparisonFailure = $e->getComparisonFailure();
if ($comparisonFailure !== NULL) {
if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Scalar) {
$buffer .= sprintf("Failed asserting that %s matches expected value %s.\n", PHPUnit_Util_Type::toString($comparisonFailure->getActual()), PHPUnit_Util_Type::toString($comparisonFailure->getExpected()));
} else {
if (PHPUnit_Framework_ComparisonFailure::hasDiff() && ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Array || $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object || $comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String)) {
$buffer .= sprintf("Failed asserting that two %ss are equal.\n%s\n", strtolower(substr(get_class($comparisonFailure), 36)), $comparisonFailure->toString());
}
}
if ($this->verbose && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Array && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_Object && !$comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure_String) {
$buffer .= $comparisonFailure->toString() . "\n";
}
} else {
$buffer .= $e->getDescription() . "\n";
}
}
} else {
if ($e instanceof PHPUnit_Framework_Error) {
$buffer = $e->getMessage() . "\n";
} else {
$buffer = get_class($e) . ': ' . $e->getMessage() . "\n";
}
}
$this->write($buffer . PHPUnit_Util_Filter::getFilteredStacktrace($defect->thrownException(), FALSE));
}
示例2: hasDiff
public static function hasDiff()
{
if (self::$hasDiff === NULL) {
self::$hasDiff = FALSE;
$binary = 'diff';
if (substr(php_uname('s'), 0, 7) == 'Windows') {
$binary .= '.exe';
}
if (isset($_ENV['PATH'])) {
$paths = explode(PATH_SEPARATOR, $_ENV['PATH']);
} else {
if (isset($_SERVER['PATH'])) {
$paths = explode(PATH_SEPARATOR, $_SERVER['PATH']);
} else {
$paths = array();
}
}
foreach ($paths as $path) {
if (file_exists($path . DIRECTORY_SEPARATOR . $binary) && is_executable($path . DIRECTORY_SEPARATOR . $binary)) {
self::$hasDiff = TRUE;
break;
}
}
}
return self::$hasDiff;
}