/** * @param object $object * @param array $attrs * * @return Dev_Unit_Assert_Iterating_Bundle */ public function assert_read($object, $attrs) { foreach ($object as $k => $v) { if (!isset($attrs[$k])) { throw new Dev_Unit_FailureException("failed: additional value in iterator for key '{$k}'"); } if (!Core::equals($v, $attrs[$k])) { throw new Dev_Unit_FailureException(sprintf("failed: unexpected value for key '{$k}': %s != %s", $this->stringify($v), $this->stringify($attrs[$k]))); } } return $this; }
/** * @param $to * * @return boolean */ public function equals($to) { if (!$to instanceof self) { return false; } if ($this->parent && !Core::equals($this->parent, $to->parent)) { return false; } foreach ($this->attrs as $k => $v) { if (!Core::equals($v, $to[$k])) { return false; } } return true; }
/** * @param $to * * @return boolean */ public function equals($to) { return $to instanceof self && Core::equals($this->values, $to->values) && Core::equals($this->parent, $to->parent); }
/** * Сравнивает две переменные произвольного типа * * @param $a * @param $b * * @return boolean */ public static function equals($a, $b) { if ($a instanceof Core_EqualityInterface) { return $a->equals($b); } if ($b instanceof Core_EqualityInterface) { return $b->equals($a); } if ($a instanceof stdClass && $b instanceof stdClass) { $a = (array) clone $a; $b = (array) clone $b; } if (is_array($a) && is_array($b) || $a instanceof ArrayObject && $b instanceof ArrayObject) { if (count($a) != count($b)) { return false; } foreach ($a as $k => $v) { if (isset($a[$k]) && !isset($b[$k]) || !Core::equals($v, $b[$k])) { return false; } } return true; } return $a === $b; }
protected function process_context($e, $ldata) { switch (true) { case isset($ldata['context']): if ($e->is_with_context() && !Core::equals($ldata['context'], $e->get_context())) { return false; } if (!$e->is_with_context()) { return false; } break; case isset($ldata['subscriber']): if ($e->is_with_context() && !$ldata['subscriber']->filter_by_context($e->get_context(), $e)) { return false; } break; case $e->is_with_context(): return false; default: if (!$e->is_with_context() && !is_null($ldata['context'])) { return false; } } return true; }
public function equals($with) { if (!$with instanceof Data_Object || !Core::equals($p = $this->get_properties(), $with->get_properties())) { return false; } foreach ($p as $v) { if (!Core::equals($this->{$v}, $with->{$v})) { return false; } } return true; }
/** * @param $a * @param $b * @param string $message * * @return Dev_Unit_TestCase */ protected function assert_same($a, $b, $message = null) { $a_replace = str_replace(' ', '', str_replace("\n", '', $a)); $b_replace = str_replace(' ', '', str_replace("\n", '', $b)); if (!Core::equals($a_replace, $b_replace)) { throw new Dev_Unit_FailureException($message ? $message : sprintf('failed: %s !~ %s', $this->stringify($a), $this->stringify($b))); } return $this; }
/** * @param $to * * @return boolean */ public function equals($to) { return get_class($this) == get_class($to) && Core::equals($this->status, $to->status) && parent::equals($to); }
/** * @param $to * * @return boolean */ public function equals($to) { return $to instanceof self && Core::equals($this->as_array(), $to->as_array()); }
/** * @param $to * * @return boolean */ public function equals($to) { $r = $to instanceof self && Core::equals($this->head, $to->head); $this_body = $this->body instanceof IO_Stream_AbstractStream || $this->body instanceof IO_FS_File ? $this->body->load() : $this->body; $to_body = $to->body instanceof IO_Stream_AbstractStream || $to->body instanceof IO_FS_File ? $to->body->load() : $to->body; return $r && Core::equals($this_body, $to_body); }
/** * @param object $object * @param array $attrs * * @return Dev_Unit_Assert_Indexing_Bundle */ public function assert_write($object, array $attrs) { foreach ($attrs as $k => $v) { $this->set_trap(); try { $object[$k] = $v; if (!Core::equals($object[$k], $v)) { throw new Dev_Unit_FailureException("failed: can't change Object[{$k}]"); } } catch (Core_MissingIndexedPropertyException $e) { $this->trap($e); } catch (Core_ReadOnlyIndexedPropertyException $e) { $this->trap($e); } catch (Core_ReadOnlyObjectException $e) { $this->trap($e); } if ($this->is_catch_prey()) { throw new Dev_Unit_FailureException("failed: can't write Object[{$k}]"); } } return $this; }
/** * @param object $object * @param array $attrs * * @return Dev_Unit_Assert_Accessing_Bundle */ public function assert_write($object, array $attrs) { foreach ($attrs as $k => $v) { $this->set_trap(); try { $object->{$k} = $v; if (!Core::equals($object->{$k}, $v)) { throw new Dev_Unit_FailureException(sprintf("failed: can't change Object->{$k}: %s != %s", $this->stringify($v), $this->stringify($object->{$k}))); } } catch (Core_MissingPropertyException $e) { $this->trap($e); } catch (Core_ReadOnlyPropertyException $e) { $this->trap($e); } catch (Core_ReadOnlyObjectException $e) { $this->trap($e); } if ($this->is_catch_prey()) { throw new Dev_Unit_FailureException("failed: can't write Object->{$k}"); } } return $this; }
/** * @param $to * * @return boolean */ public function equals($to) { return get_class($this) === get_class($to) && $this->name == $to->name && $this->http_mask == $to->http_mask && Core::equals($this->path, $to->path) && Core::equals($this->formats, $to->formats); }