示例#1
0
文件: Iterating.php 项目: techart/tao
 /**
  * @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;
 }
示例#2
0
文件: WS.php 项目: techart/tao
 /**
  * @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;
 }
示例#3
0
文件: Log.php 项目: techart/tao
 /**
  * @param  $to
  *
  * @return boolean
  */
 public function equals($to)
 {
     return $to instanceof self && Core::equals($this->values, $to->values) && Core::equals($this->parent, $to->parent);
 }
示例#4
0
文件: Core.php 项目: techart/tao
 /**
  * Сравнивает две переменные произвольного типа
  *
  * @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;
 }
示例#5
0
文件: Events.php 项目: techart/tao
 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;
 }
示例#6
0
文件: Data.php 项目: techart/tao
 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;
 }
示例#7
0
文件: Unit.php 项目: techart/tao
 /**
  * @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;
 }
示例#8
0
文件: HTTP.php 项目: techart/tao
 /**
  * @param  $to
  *
  * @return boolean
  */
 public function equals($to)
 {
     return get_class($this) == get_class($to) && Core::equals($this->status, $to->status) && parent::equals($to);
 }
示例#9
0
文件: AdWords.php 项目: techart/tao
 /**
  * @param  $to
  *
  * @return boolean
  */
 public function equals($to)
 {
     return $to instanceof self && Core::equals($this->as_array(), $to->as_array());
 }
示例#10
0
文件: Message.php 项目: techart/tao
 /**
  * @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);
 }
示例#11
0
文件: Indexing.php 项目: techart/tao
 /**
  * @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;
 }
示例#12
0
文件: Accessing.php 项目: techart/tao
 /**
  * @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;
 }
示例#13
0
文件: REST.php 项目: techart/tao
 /**
  * @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);
 }