本文整理汇总了PHP中Hamcrest\Description::appendText方法的典型用法代码示例。如果您正苦于以下问题:PHP Description::appendText方法的具体用法?PHP Description::appendText怎么用?PHP Description::appendText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hamcrest\Description
的用法示例。
在下文中一共展示了Description::appendText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: describeMismatch
public function describeMismatch($item, Description $description)
{
if ($item === null) {
$description->appendText('was null');
} else {
$description->appendText('was ')->appendText(self::getTypeDescription(strtolower(gettype($item))))->appendText(' ')->appendValue($item);
}
}
示例2: describeTo
public function describeTo(Description $description)
{
$description->appendText('a value ')->appendText($this->_comparison($this->_minCompare));
if ($this->_minCompare != $this->_maxCompare) {
$description->appendText(' or ')->appendText($this->_comparison($this->_maxCompare));
}
$description->appendText(' ')->appendValue($this->_value);
}
示例3: matchesWithDiagnosticDescription
protected function matchesWithDiagnosticDescription($item, Description $mismatchDescription)
{
if (!is_object($item)) {
$mismatchDescription->appendText('was ')->appendValue($item);
return false;
}
if (!$item instanceof $this->_theClass) {
$mismatchDescription->appendText('[' . get_class($item) . '] ')->appendValue($item);
return false;
}
return true;
}
示例4: describeTo
public function describeTo(Description $description)
{
$textStart = 0;
while (preg_match(self::ARG_PATTERN, $this->_descriptionTemplate, $matches, PREG_OFFSET_CAPTURE, $textStart)) {
$text = $matches[0][0];
$index = $matches[1][0];
$offset = $matches[0][1];
$description->appendText(substr($this->_descriptionTemplate, $textStart, $offset - $textStart));
$description->appendValue($this->_values[$index]);
$textStart = $offset + strlen($text);
}
if ($textStart < strlen($this->_descriptionTemplate)) {
$description->appendText(substr($this->_descriptionTemplate, $textStart));
}
}
示例5: describe
/**
* Describe the contents of the given <code>list</code> in the given <code>description</code>.
*
* @param array $list The list to describe
* @param Description $description The description to describe to
*/
public static function describe(array $list, Description $description)
{
$counter = 0;
$description->appendText("List with ");
foreach ($list as $item) {
$description->appendText("<")->appendText(null !== $item ? get_class($item) : "null")->appendText(">");
if ($counter === count($list) - 2) {
$description->appendText(" and ");
} else {
if ($counter < count($list) - 2) {
$description->appendText(", ");
}
}
$counter++;
}
}
示例6: describeMismatchSafely
protected function describeMismatchSafely($actual, Description $mismatchDescription)
{
if (count($actual) != count($this->_elementMatchers)) {
$mismatchDescription->appendText('array length was ' . count($actual));
return;
} elseif (array_keys($actual) != array_keys($this->_elementMatchers)) {
$mismatchDescription->appendText('array keys were ')->appendValueList($this->descriptionStart(), $this->descriptionSeparator(), $this->descriptionEnd(), array_keys($actual));
return;
}
/** @var $matcher \Hamcrest\Matcher */
foreach ($this->_elementMatchers as $k => $matcher) {
if (!$matcher->matches($actual[$k])) {
$mismatchDescription->appendText('element ')->appendValue($k)->appendText(' was ')->appendValue($actual[$k]);
return;
}
}
}
示例7: describeMismatch
public function describeMismatch($item, Description $description)
{
$value = '';
if (!$this->_not) {
$description->appendText('was not set');
} else {
$property = $this->_property;
if (is_array($item)) {
$value = $item[$property];
} elseif (is_object($item)) {
$value = $item->{$property};
} elseif (is_string($item)) {
$value = $item::${$property};
}
parent::describeMismatch($value, $description);
}
}
示例8: describeTo
public function describeTo(Description $description)
{
$description->appendText($this->_empty ? 'an empty string' : 'a non-empty string');
}
示例9: describeTo
public function describeTo(Description $description)
{
$description->appendText('a string containing ')->appendValueList('', ', ', '', $this->_substrings)->appendText(' in order');
}
示例10: describeTo
public function describeTo(Description $description)
{
$description->appendText("<nothing>");
}
示例11: describeTo
public function describeTo(Description $description)
{
$description->appendText('array with key ')->appendDescriptionOf($this->_keyMatcher);
}
示例12: describeTo
public function describeTo(Description $description)
{
$description->appendText('an instance of ')->appendText($this->_theClass);
}
示例13: describeTo
public function describeTo(Description $description)
{
$description->appendText('every item is ')->appendDescriptionOf($this->_matcher);
}
示例14: describeTo
public function describeTo(Description $description)
{
$description->appendText('array containing [')->appendDescriptionOf($this->_keyMatcher)->appendText(' => ')->appendDescriptionOf($this->_valueMatcher)->appendText(']');
}
示例15: describeCollectionType
protected function describeCollectionType(Description $description)
{
$description->appendText("exact sequence");
}