예제 #1
0
 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);
     }
 }
 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
0
 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;
 }
 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
0
 /**
  * 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
0
 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);
     }
 }
예제 #7
0
 public function describeTo(Description $description)
 {
     $description->appendValue($this->_item);
 }
 public function describeTo(Description $description)
 {
     $description->appendText('null');
 }
 public function describeTo(Description $description)
 {
     $description->appendDescriptionOf($this->_matcher);
 }
 public function describeTo(Description $description)
 {
     $description->appendText($this->_empty ? 'an empty traversable' : 'a non-empty traversable');
 }
 public function describeTo(Description $description)
 {
     $description->appendList('[', ', ', ']', $this->_elementMatchers)->appendText(' in any order');
 }
 public function describeTo(Description $description)
 {
     $description->appendList('[', ', ', ']', $this->_elementMatchers);
 }
 protected function describeMismatchSafely($item, Description $mismatchDescription)
 {
     $mismatchDescription->appendText('was ')->appendText($item);
 }
예제 #14
0
 public function describeTo(Description $description)
 {
     $description->appendText('an instance of ')->appendText($this->_theClass);
 }
예제 #15
0
 public function describeTo(Description $description)
 {
     $description->appendText('every item is ')->appendDescriptionOf($this->_matcher);
 }
예제 #16
0
 public function describeTo(Description $description)
 {
     $description->appendText('a string ')->appendText($this->relationship())->appendText(' ')->appendValue($this->_substring);
 }
예제 #17
0
 protected function describeMismatchSafely($item, Description $mismatchDescription)
 {
     $mismatchDescription->appendValue($item)->appendText(' differed by ')->appendValue($this->_actualDelta($item));
 }
 public function describeTo(Description $description)
 {
     $description->appendText('equalToIgnoringWhiteSpace(')->appendValue($this->_string)->appendText(')');
 }
예제 #19
0
 protected function describeCollectionType(Description $description)
 {
     $description->appendText("any");
 }
 public function describeTo(Description $description)
 {
     $description->appendText('array containing [')->appendDescriptionOf($this->_keyMatcher)->appendText(' => ')->appendDescriptionOf($this->_valueMatcher)->appendText(']');
 }
예제 #21
0
 public function describeTo(Description $description)
 {
     $description->appendText('XML or HTML document with XPath "')->appendText($this->_xpath)->appendText('"');
     if ($this->_matcher !== null) {
         $description->appendText(' ');
         $this->_matcher->describeTo($description);
     }
 }
예제 #22
0
 public function describeTo(Description $description)
 {
     $description->appendText('array with key ')->appendDescriptionOf($this->_keyMatcher);
 }
예제 #23
0
 public function describeTo(Description $description)
 {
     $description->appendText('a collection containing ')->appendDescriptionOf($this->_elementMatcher);
 }
예제 #24
0
 public function describeTo(Description $description)
 {
     $description->appendList($this->descriptionStart(), $this->descriptionSeparator(), $this->descriptionEnd(), $this->_elementMatchers);
 }
 public function describeTo(Description $description)
 {
     $description->appendText('sameInstance(')->appendValue($this->_object)->appendText(')');
 }
예제 #26
0
 public function describeTo(\Hamcrest\Description $description)
 {
     $description->appendText('SOME DESCRIPTION');
 }
예제 #27
0
 public function describeTo(Description $description)
 {
     $description->appendText('a numeric value within ')->appendValue($this->_delta)->appendText(' of ')->appendValue($this->_value);
 }
 public function describeTo(Description $description)
 {
     $description->appendText('a string containing ')->appendValueList('', ', ', '', $this->_substrings)->appendText(' in order');
 }
 public function describeToWithOperator(Description $description, $operator)
 {
     $description->appendList('(', ' ' . $operator . ' ', ')', $this->_matchers);
 }
예제 #30
0
 public function describeTo(Description $description)
 {
     $description->appendText($this->_empty ? 'an empty string' : 'a non-empty string');
 }