public function testRef()
 {
     ini_set("mongo.cmd", ":");
     $this->object->insert(array("_id" => 123, "hello" => "world"));
     $this->object->insert(array("_id" => 456, "ref" => array(":ref" => "bar", ":id" => 123)));
     $ref = $this->object->findOne(array("_id" => 456));
     $obj = MongoDBRef::get($this->object->db, $ref["ref"]);
     $this->assertNotNull($obj);
     $this->assertEquals("world", $obj["hello"], json_encode($obj));
 }
 public function testGetDBRef()
 {
     for ($i = 0; $i < 50; $i++) {
         $this->object->insert((object) array('x' => rand()));
     }
     $obj = $this->object->findOne();
     $ref = $this->object->createDBRef($obj);
     $obj2 = $this->object->getDBRef($ref);
     $this->assertNotNull($obj2);
     $this->assertEquals($obj['x'], $obj2['x']);
 }
 /**
  * Method used to read from a database session.
  *
  * @param mixed $id The key of the value to read
  * @return mixed The value of the key or false if it does not exist
  * @access private
  */
 public function __read($id)
 {
     // obtain a read lock on the data, or subsequently wait for
     // the lock to be released
     //		$this->_lock($id);
     // exclude results that are inactive or expired
     $result = $this->_mongo->findOne(array('session_id' => $id, 'expiry' => array('$gte' => time()), 'active' => 1));
     if (isset($result['data'])) {
         $this->_session = $result;
         return $result['data'];
     }
     return '';
 }