本文整理汇总了PHP中PHPUnit_Util_Type::export方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Type::export方法的具体用法?PHP PHPUnit_Util_Type::export怎么用?PHP PHPUnit_Util_Type::export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Type
的用法示例。
在下文中一共展示了PHPUnit_Util_Type::export方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toString
/**
* {@inheritdoc}
*
* @todo Improve output using diff when expected and actual arguments of a
* command do not match.
*/
public function toString()
{
$string = 'is a Redis command';
if ($this->commandID) {
$string .= " with ID '{$this->commandID}'";
}
if ($this->arguments) {
$string .= " and the following arguments:\n\n";
$string .= PHPUnit_Util_Type::export($this->arguments);
}
return $string;
}
示例2: invoke
/**
* @param PHPUnit_Framework_MockObject_Invocation $invocation
* @return the invocation of the Entry with matching parameters.
*/
public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
{
foreach ($this->return_map as $entry) {
if ($entry->matches($invocation)) {
return $entry->invoke($invocation);
}
}
if ($this->default != NULL) {
return $this->default->invoke($invocation);
}
PHPUnit_Framework_Assert::fail(sprintf('No return value defined for %s', PHPUnit_Util_Type::export($invocation->parameters)));
}
示例3: assertArraySameValues
public static function assertArraySameValues($expected, $actual)
{
$extra = array_diff($expected, $actual);
$missing = array_diff($actual, $expected);
CakeTestCase::assertSame($extra, $missing, "Got extra elements " . PHPUnit_Util_Type::export($extra) . " and some are elements missing " . PHPUnit_Util_Type::export($missing));
}
示例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)
{
if (is_infinite($actual) && is_infinite($expected)) {
return;
}
if ((is_infinite($actual) xor is_infinite($expected)) || (is_nan($actual) or is_nan($expected)) || abs($actual - $expected) > $delta) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, '', '', FALSE, sprintf('Failed asserting that %s matches expected %s.', PHPUnit_Util_Type::export($actual), PHPUnit_Util_Type::export($expected)));
}
}
示例5: 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 ($actual != $expected) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, PHPUnit_Util_Type::export($expected), PHPUnit_Util_Type::export($actual));
}
}
示例6: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
if (is_string($this->value) && strpos($this->value, "\n") !== FALSE) {
return 'contains "' . $this->value . '"';
} else {
return 'contains ' . PHPUnit_Util_Type::export($this->value);
}
}
示例7: toString
public function toString()
{
return sprintf('has items %s', PHPUnit_Util_Type::export($this->expected));
}
示例8: getNumber
/**
* Send a command to the Selenium RC server and treat the result
* as a number.
*
* @param string $command
* @param array $arguments
* @return numeric
* @author Shin Ohno <ganchiku@gmail.com>
* @author Bjoern Schotte <schotte@mayflower.de>
*/
protected function getNumber($command, array $arguments)
{
$result = $this->getString($command, $arguments);
if (!is_numeric($result)) {
throw new PHPUnit_Framework_Exception('Result is not numeric: ' . PHPUnit_Util_Type::export($result));
}
return $result;
}
示例9: 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)
{
$expectedToCompare = $expected;
$actualToCompare = $actual;
// always compare as strings to avoid strange behaviour
// otherwise 0 == 'Foobar'
if (is_string($expected) || is_string($actual)) {
$expectedToCompare = (string) $expectedToCompare;
$actualToCompare = (string) $actualToCompare;
if ($ignoreCase) {
$expectedToCompare = strtolower($expectedToCompare);
$actualToCompare = strtolower($actualToCompare);
}
}
if ($expectedToCompare != $actualToCompare) {
if (is_string($expected) && is_string($actual)) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, PHPUnit_Util_Type::export($expected), PHPUnit_Util_Type::export($actual), FALSE, 'Failed asserting that two strings are equal.');
}
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, '', '', FALSE, sprintf('Failed asserting that %s matches expected %s.', PHPUnit_Util_Type::export($actual), PHPUnit_Util_Type::export($expected)));
}
}
示例10: 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)
{
foreach ($actual as $object) {
if (!$expected->contains($object)) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, PHPUnit_Util_Type::export($expected), PHPUnit_Util_Type::export($actual), false, 'Failed asserting that two objects are equal.');
}
}
foreach ($expected as $object) {
if (!$actual->contains($object)) {
throw new PHPUnit_Framework_ComparisonFailure($expected, $actual, PHPUnit_Util_Type::export($expected), PHPUnit_Util_Type::export($actual), false, 'Failed asserting that two objects are equal.');
}
}
}
示例11: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'has the same values with ' . PHPUnit_Util_Type::export($this->value);
}
示例12: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return sprintf('%s Reason: %s', PHPUnit_Util_Type::export($this->value), $this->failure_reason);
}
示例13: toString
public function toString()
{
return sprintf('equals ignoring whitespace %s', PHPUnit_Util_Type::export($this->normalize($this->expected)));
}
示例14: 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.');
}
}
示例15: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'has the key ' . PHPUnit_Util_Type::export($this->key);
}