예제 #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
 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
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);
     }
 }
예제 #8
0
 public function describeTo(Description $description)
 {
     $description->appendText($this->_empty ? 'an empty string' : 'a non-empty string');
 }
 public function describeTo(Description $description)
 {
     $description->appendText('a string containing ')->appendValueList('', ', ', '', $this->_substrings)->appendText(' in order');
 }
예제 #10
0
 public function describeTo(Description $description)
 {
     $description->appendText("<nothing>");
 }
예제 #11
0
 public function describeTo(Description $description)
 {
     $description->appendText('array with key ')->appendDescriptionOf($this->_keyMatcher);
 }
예제 #12
0
 public function describeTo(Description $description)
 {
     $description->appendText('an instance of ')->appendText($this->_theClass);
 }
예제 #13
0
 public function describeTo(Description $description)
 {
     $description->appendText('every item is ')->appendDescriptionOf($this->_matcher);
 }
 public function describeTo(Description $description)
 {
     $description->appendText('array containing [')->appendDescriptionOf($this->_keyMatcher)->appendText(' => ')->appendDescriptionOf($this->_valueMatcher)->appendText(']');
 }
예제 #15
0
 protected function describeCollectionType(Description $description)
 {
     $description->appendText("exact sequence");
 }
 protected function describeMismatchSafely($item, Description $mismatchDescription)
 {
     $mismatchDescription->appendText('was ')->appendText($item);
 }
 public function describeTo(Description $description)
 {
     $description->appendText($this->_message);
 }
예제 #18
0
 protected function describeCollectionType(Description $description)
 {
     $description->appendText("any");
 }
예제 #19
0
 public function describeTo(Description $description)
 {
     $description->appendText('a string ')->appendText($this->relationship())->appendText(' ')->appendValue($this->_substring);
 }
 public function describeTo(Description $description)
 {
     $description->appendText($this->_empty ? 'an empty traversable' : 'a non-empty traversable');
 }
 public function describeTo(Description $description)
 {
     $description->appendText('null');
 }
 public function describeTo(Description $description)
 {
     $description->appendText('equalToIgnoringWhiteSpace(')->appendValue($this->_string)->appendText(')');
 }
예제 #23
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);
     }
 }
 /**
  * @param \Hamcrest\Description $description
  */
 public function describeTo(Description $description)
 {
     $description->appendText("no ");
     $description->appendText($this->contentDescription);
 }
예제 #25
0
 public function describeTo(Description $description)
 {
     $description->appendText('a collection containing ')->appendDescriptionOf($this->_elementMatcher);
 }
예제 #26
0
 public function describeTo(Description $description)
 {
     $description->appendText("list with ");
     $this->describeCollectionType($description);
     $description->appendText(" of: ");
     for ($t = 0; $t < count($this->matchers); $t++) {
         if ($t !== 0 && $t < count($this->matchers) - 1) {
             $description->appendText(", ");
         } else {
             if ($t === count($this->matchers) - 1 && $t > 0) {
                 $description->appendText(" ");
                 $description->appendText($this->getLastSeparator());
                 $description->appendText(" ");
             }
         }
         $description->appendText("<");
         $this->matchers[$t]->describeTo($description);
         $description->appendText(">");
         if (in_array($this->matchers[$t], $this->failedMatchers, true)) {
             $description->appendText(" (");
             $description->appendText($this->failedMatcherMessage());
             $description->appendText(")");
         }
     }
 }
 public function describeTo(Description $description)
 {
     $description->appendText('sameInstance(')->appendValue($this->_object)->appendText(')');
 }
예제 #28
0
 public function describeTo(\Hamcrest\Description $description)
 {
     $description->appendText('SOME DESCRIPTION');
 }
예제 #29
0
 public function describeTo(Description $description)
 {
     $description->appendText('a numeric value within ')->appendValue($this->_delta)->appendText(' of ')->appendValue($this->_value);
 }
 public function describeTo(\Hamcrest\Description $description)
 {
     $description->appendText($this->_text);
 }