本文整理汇总了PHP中PHPUnit_Util_Type类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Type类的具体用法?PHP PHPUnit_Util_Type怎么用?PHP PHPUnit_Util_Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Util_Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toString
public function toString()
{
return sprintf(
'return user-specified value %s',
PHPUnit_Util_Type::toString($this->value)
);
}
示例2: toString
public function toString()
{
return sprintf(
'raise user-specified exception %s',
PHPUnit_Util_Type::toString($this->exception)
);
}
示例3: 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);
}
}
PHPUnit_Framework_Assert::fail(sprintf('No return value defined for %s', PHPUnit_Util_Type::toString($invocation->parameters)));
}
示例4: toString
/**
* Returns a string describing the type difference between the expected
* and the actual value.
*/
public function toString()
{
return sprintf(
'%s does not match expected type "%s".',
PHPUnit_Util_Type::toString($this->actual),
gettype($this->expected)
);
}
示例5: getActualValue
/**
* For layout, actual value should be always set
* (non-PHPdoc)
* @see Mage_PHPUnit_Constraint_Abstract::getActualValue()
*/
protected function getActualValue($other)
{
if ($this->_useActualValue) {
if (is_array($this->_actualValue)) {
return PHPUnit_Util_Type::toString($this->_actualValue);
}
return parent::getActualValue($other);
}
return '';
}
示例6: toString
/**
* Returns a string describing the difference between the expected and the
* actual scalar value.
*/
public function toString()
{
return sprintf(
'Failed asserting that %s %s %s.',
PHPUnit_Util_Type::toString($this->actual),
$this->identical ? 'is identical to' : 'matches expected',
PHPUnit_Util_Type::toString($this->expected)
);
}
示例7: evaluateValid
/**
* Evaluate that string is valid JSON
*
* @param string $other
* @return boolean
*/
protected function evaluateValid($other)
{
try {
$decodedJson = Zend_Json::decode($other);
$this->setActualValue($decodedJson);
} catch (Zend_Json_Exception $e) {
$this->setActualValue(PHPUnit_Util_Type::shortenedString($other) . "\n" . $e->__toString());
return false;
}
return true;
}
示例8: getActualValue
/**
* Returning user friendly actual value
* (non-PHPdoc)
* @see Mage_PHPUnit_Constraint_Abstract::getActualValue()
*/
protected function getActualValue($other)
{
if ($this->_useActualValue) {
if ($this->_actualValue instanceof Varien_Object) {
$value = $this->_actualValue->debug();
} else {
$value = $this->_actualValue;
}
return PHPUnit_Util_Type::toString($value);
}
return '';
}
示例9: 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;
}
示例10: fail
public function fail($other, $description, \SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL)
{
throw new PHPUnit_Framework_ExpectationFailedException(sprintf('%sFailed asserting that %s contains a query element that restricts the search to groups', !empty($description) ? $description . "\n" : '', PHPUnit_Util_Type::toString($other, TRUE)), NULL);
}
示例11: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'is greater than ' . PHPUnit_Util_Type::toString($this->value);
}
示例12: 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)));
}
}
示例13: toString
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'has the key ' . PHPUnit_Util_Type::toString($this->key);
}
示例14: shortenedString
public static function shortenedString($string)
{
$string = preg_replace('#\\n|\\r\\n|\\r#', ' ', $string);
if (strlen($string) > 14) {
return PHPUnit_Util_Type::toString(substr($string, 0, 7) . '...' . substr($string, -7));
} else {
return PHPUnit_Util_Type::toString($string);
}
}
示例15: testNonBinaryStringExport
/**
* @dataProvider provideNonBinaryMultibyteStrings
*/
public function testNonBinaryStringExport($value, $expectedLength)
{
$this->assertRegExp("~'.{{$expectedLength}}'\$~s", PHPUnit_Util_Type::export($value));
}