/** * Generates a description of the object. The description may be part * of a description of a larger object of which this is just a component, * so it should be worded appropriately. * * @param Hamcrest_Description $description * The description to be built or appended to. */ public function describeTo(\Hamcrest_Description $description) { if (empty($this->description)) { foreach ($this->expected as $expected) { $description->appendValue($expected); } } else { $description->appendText($this->description); } }
protected function describeMismatchSafely($array, Hamcrest_Description $mismatchDescription) { //Not using appendValueList() so that keys can be shown $mismatchDescription->appendText('array was ')->appendText('['); $loop = false; foreach ($array as $key => $value) { if ($loop) { $mismatchDescription->appendText(', '); } $mismatchDescription->appendValue($key)->appendText(' => ')->appendValue($value); $loop = true; } $mismatchDescription->appendText(']'); }
public function describeTo(Hamcrest_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)); } }
public function describeTo(Hamcrest_Description $description) { $description->appendValue($this->_item); }
protected function describeMismatchSafely($item, Hamcrest_Description $mismatchDescription) { $mismatchDescription->appendValue($item)->appendText(' differed by ')->appendValue($this->_actualDelta($item)); }
protected function describeMismatchSafely($item, Hamcrest_Description $mismatchDescription) { $mismatchDescription->appendValue($item)->appendText(' was ')->appendText($this->_comparison($this->_compare($this->_value, $item)))->appendText(' ')->appendValue($this->_value); }