You are here

function ArrayWithinMarginExpectation::_outsideMessage in Location 5.3

Creates a the message for being within the range.

Parameters

mixed $compare Value being tested.: @access private

File

tests/location_test_case.php, line 70
Location specific assertions.

Class

ArrayWithinMarginExpectation
Test each element of an array for being within a range.

Code

function _outsideMessage($compare) {
  if (count($compare) != count($this->_canonicalvalues)) {
    return 'Expectation failed, array size mismatch [(' . implode(',', $compare) . ') and (' . implode(',', $this->_canonicalvalues) . ')]';
  }
  $differror = array();
  foreach ($compare as $k => $v) {
    $differror[$k] = 'OK';
    if ($v > $this->_upper[$k]) {
      $differror[$k] = '+' . ($v - $this->_upper[$k]);
    }
    if ($v < $this->_lower[$k]) {
      $differror[$k] = '-' . ($this->_lower[$k] - $v);
    }
  }
  return 'Outside expectation [(' . implode(',', $compare) . ') and (' . implode(',', $this->_canonicalvalues) . ') exceed margin ' . $this->_margin . ' by (' . implode(',', $differror) . ')]';
}