/** * @test */ public function merge() { $object = new Sabel_ValueObject(); $object->a = 10; $object->b = 20; $this->assertEquals(2, count($object->toArray())); $object->merge(array("c" => 30, "d" => 40)); $this->assertEquals(4, count($object->toArray())); $object2 = new Sabel_ValueObject(); $object2->e = 50; $object2->f = 60; $object->merge($object2); $this->assertEquals(6, count($object->toArray())); $this->assertEquals(10, $object->a); $this->assertEquals(20, $object->b); $this->assertEquals(30, $object->c); $this->assertEquals(40, $object->d); $this->assertEquals(50, $object->e); $this->assertEquals(60, $object->f); }
protected function getUserData() { $userId = $this->userId; $cache = UserCache::getInstance(); $data = $cache->read($userId); if ((ENVIRONMENT & PRODUCTION) > 0 && !$data) { list($fp) = $cache->lock($userId); $data = $this->_getUserData($userId); $cache->write($fp, $data); } if (!$data) { $data = $this->_getUserData($userId); } return Sabel_ValueObject::fromArray(array("userId" => $userId, "friends" => Follower::getFriends($userId, FRIENDS_ICON_LIMIT + 1), "friendsCount" => $data["friends"], "followersCount" => $data["followers"], "statusesCount" => $data["statuses"], "latestComment" => $data["comment"])); }