本文整理汇总了PHP中PHPUnit_Util_Type::shortenedExport方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Type::shortenedExport方法的具体用法?PHP PHPUnit_Util_Type::shortenedExport怎么用?PHP PHPUnit_Util_Type::shortenedExport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Type
的用法示例。
在下文中一共展示了PHPUnit_Util_Type::shortenedExport方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShortenedExport
/**
* @dataProvider shortenedExportProvider
*/
public function testShortenedExport($value, $expected)
{
$this->assertSame($expected, self::trimnl(PHPUnit_Util_Type::shortenedExport($value)));
}
示例2: assertEquals
/**
* Asserts that two values are equal.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param float $delta The allowed numerical distance between two values to
* consider them equal
* @param bool $canonicalize If set to TRUE, arrays are sorted before
* comparison
* @param bool $ignoreCase If set to TRUE, upper- and lowercasing is
* ignored when comparing string values
* @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison
* fails. Contains information about the
* specific errors that lead to the failure.
*/
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE)
{
if (gettype($expected) != gettype($actual)) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, '', '', FALSE, sprintf('%s does not match expected type "%s".', PHPUnit_Util_Type::shortenedExport($actual), gettype($expected)));
}
}
示例3: failureDescription
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @return string
*/
protected function failureDescription($other)
{
return sprintf('%s is an instance of class "%s"', PHPUnit_Util_Type::shortenedExport($other), $this->className);
}
示例4: assertEquals
/**
* Asserts that two values are equal.
*
* @param mixed $expected The first value to compare
* @param mixed $actual The second value to compare
* @param float $delta The allowed numerical distance between two values to
* consider them equal
* @param bool $canonicalize If set to TRUE, arrays are sorted before
* comparison
* @param bool $ignoreCase If set to TRUE, upper- and lowercasing is
* ignored when comparing string values
* @throws PHPUnit_Framework_ComparisonFailure Thrown when the comparison
* fails. Contains information about the
* specific errors that lead to the failure.
*/
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array())
{
if ($canonicalize) {
sort($expected);
sort($actual);
}
$remaining = $actual;
$expString = $actString = "Array (\n";
$equal = TRUE;
foreach ($expected as $key => $value) {
unset($remaining[$key]);
if (!array_key_exists($key, $actual)) {
$expString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), PHPUnit_Util_Type::shortenedExport($value));
$equal = FALSE;
continue;
}
try {
$this->factory->getComparatorFor($value, $actual[$key])->assertEquals($value, $actual[$key], $delta, $canonicalize, $ignoreCase, $processed);
$expString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), PHPUnit_Util_Type::shortenedExport($value));
$actString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), PHPUnit_Util_Type::shortenedExport($actual[$key]));
} catch (PHPUnit_Framework_ComparisonFailure $e) {
$expString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), $e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : PHPUnit_Util_Type::shortenedExport($e->getExpected()));
$actString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), $e->getActualAsString() ? $this->indent($e->getActualAsString()) : PHPUnit_Util_Type::shortenedExport($e->getActual()));
$equal = FALSE;
}
}
foreach ($remaining as $key => $value) {
$actString .= sprintf(" %s => %s\n", PHPUnit_Util_Type::export($key), PHPUnit_Util_Type::shortenedExport($value));
$equal = FALSE;
}
$expString .= ')';
$actString .= ')';
if (!$equal) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, $expString, $actString, FALSE, 'Failed asserting that two arrays are equal.');
}
}
示例5: failureDescription
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
* @return string
*/
protected function failureDescription($other)
{
json_decode($other);
$error = PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider::determineJsonError(json_last_error());
return sprintf('%s is valid JSON (%s)', PHPUnit_Util_Type::shortenedExport($other), $error);
}