Beispiel #1
0
 /**
  *    Recursive type test for each element of an array.
  *    @param mixed $first    Test subject.
  *    @param mixed $second   Comparison object.
  *    @return boolean        True if identical.
  *    @access private
  */
 protected static function isArrayOfIdenticalTypes($first, $second)
 {
     if (array_keys($first) != array_keys($second)) {
         return false;
     }
     foreach (array_keys($first) as $key) {
         $is_identical = SimpleTestCompatibility::isIdentical($first[$key], $second[$key]);
         if (!$is_identical) {
             return false;
         }
     }
     return true;
 }
 /**
  *    Tests the expectation. True if it exactly
  *    matches the held value.
  *    @param mixed $compare        Comparison value.
  *    @return boolean              True if correct.
  *    @access public
  */
 function test($compare)
 {
     return SimpleTestCompatibility::isIdentical($this->_getValue(), $compare);
 }
Beispiel #3
0
 /**
  *    Identity test. Drops back to equality for PHP5
  *    objects as the === operator counts as the
  *    stronger reference constraint.
  *    @param mixed $first    Test subject.
  *    @param mixed $second   Comparison object.
  *    @access public
  *    @static
  */
 function isIdentical($first, $second)
 {
     if (version_compare(phpversion(), '5') >= 0) {
         if (gettype($first) != gettype($second)) {
             return false;
         }
         if ($first != $second) {
             return false;
         }
         if (is_object($first) && is_object($second)) {
             return get_class($first) == get_class($second);
         }
         if (is_array($first) && is_array($second)) {
             if (array_keys($first) != array_keys($second)) {
                 return false;
             }
             foreach (array_keys($first) as $key) {
                 if (!SimpleTestCompatibility::isIdentical($first[$key], $second[$key])) {
                     return false;
                 }
             }
         }
         return true;
     }
     return $first === $second;
 }
Beispiel #4
0
 /**
  * Tests the expectation. True if it exactly matches the held value.
  *
  * @param mixed $compare Comparison value.
  * @return boolean
  */
 public function test($compare)
 {
     $value = $this->entityToFilteredArray($this->getValue());
     $compare = $this->entityToFilteredArray($compare);
     return SimpleTestCompatibility::isIdentical($value, $compare);
 }