예제 #1
0
 /**
  *  test updating maps
  *  
  *  requires update() and getOne() to be implemented 
  */
 public function testUpdate()
 {
     $limit = 10;
     $db = $this->getDb();
     $table = $this->getTable(__FUNCTION__);
     $_id_list = $this->insert($table, $limit);
     $time = microtime(true);
     foreach ($_id_list as $_id) {
         $map = array('_id' => $_id, 'bar' => $time);
         $map = $db->set($table, $map);
         $this->assertInternalType('array', $map);
         $this->assertArrayHasKey('_id', $map);
         $this->assertArrayHasKey('bar', $map);
         $this->assertEquals($time, $map['bar']);
         // now pull from db to make sure it really did get updated...
         $where_criteria = new MingoCriteria();
         $where_criteria->is_id($_id);
         $map = $db->getOne($table, $where_criteria);
         $this->assertInternalType('array', $map);
         $this->assertArrayHasKey('_id', $map);
         $this->assertArrayHasKey('bar', $map);
         // for some reason, casting the 'bar' to a double didn't work to make the types match
         $this->assertEquals((string) $time, (string) $map['bar']);
     }
     //foreach
 }