Permalink
Browse files

print_r() -> PHPUnit_Util_Type::toString()

  • Loading branch information...
1 parent 5c70cdc commit 6d18e6a10541b6a8b792d4a14c5cb43942359486 @sebastianbergmann committed Nov 13, 2006
@@ -47,6 +47,7 @@
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Type.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
@@ -200,7 +201,7 @@ public static function shortenedExport($value)
elseif (is_array($v1)) {
$v1 = 'array(...)';
} else {
- $v1 = print_r($v1, TRUE);
+ $v1 = PHPUnit_Util_Type::toString($v1);
}
$a2 = false;
@@ -217,14 +218,14 @@ public static function shortenedExport($value)
elseif (is_array($v2)) {
$v2 = 'array(...)';
} else {
- $v2 = print_r($v2, TRUE);
+ $v2 = PHPUnit_Util_Type::toString($v2);
}
}
- $text = 'array( ' . print_r($k1, TRUE) . ' => ' . $v1;
+ $text = 'array( ' . PHPUnit_Util_Type::toString($k1) . ' => ' . $v1;
if ($a2 !== FALSE) {
- $text .= ', ..., ' . print_r($k2, TRUE) . ' => ' . $v2 . ' )';
+ $text .= ', ..., ' . PHPUnit_Util_Type::toString($k2) . ' => ' . $v2 . ' )';
} else {
$text .= ' )';
}
@@ -236,7 +237,7 @@ public static function shortenedExport($value)
return 'class ' . get_class($value) . '(...)';
}
- return print_r($value, TRUE);
+ return PHPUnit_Util_Type::toString($value);
}
/**
@@ -251,9 +252,9 @@ private static function shortenedString($string)
$string = preg_replace('#\n|\r\n|\r#', ' ', $string);
if (strlen($string) > 14) {
- return print_r(substr($string, 0, 7), TRUE) . '...' . print_r(substr($string, -7), TRUE);
+ return PHPUnit_Util_Type::toString(substr($string, 0, 7) . '...' . substr($string, -7));
} else {
- return print_r($string, TRUE);
+ return PHPUnit_Util_Type::toString($string);
}
}
}
@@ -111,7 +111,7 @@ public function toString()
$actualValue = '';
if (is_string($this->actual) || is_bool($this->actual) || is_int($this->actual) || is_float($this->actual)) {
- $actualValue = '<' . print_r($this->actual, TRUE) . '>';
+ $actualValue = PHPUnit_Util_Type::toString($this->actual);
}
elseif (is_object($this->actual)) {
@@ -124,7 +124,7 @@ public function toString()
$expectedValue = '<' . $this->expected . '>';
} else {
if (is_string($this->expected) || is_bool($this->expected) || is_int($this->expected) || is_float($this->expected)) {
- $expectedValue = '<' . print_r($this->expected, TRUE) . '>';
+ $expectedValue = PHPUnit_Util_Type::toString($this->expected);
}
elseif (is_object($this->expected)) {
@@ -88,9 +88,9 @@ public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
public function toString()
{
return sprintf(
- 'return the user-specified value <%s>',
+ 'return user-specified value %s',
- print_r($this->value, TRUE)
+ PHPUnit_Util_Type::toString($this->value)
);
}
}
@@ -81,9 +81,9 @@ public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
public function toString()
{
return sprintf(
- 'return the user-specified value <%s>',
+ 'return user-specified value %s',
- print_r($this->value, TRUE)
+ PHPUnit_Util_Type::toString($this->value)
);
}
}

0 comments on commit 6d18e6a

Please sign in to comment.