public function testEnsureIndex() {
      setTimezone();

      $mongoConnection = new Mongo('127.0.0.1:27017');
      $collection = $mongoConnection->selectCollection("debug", "col1");
      $data = array("field"=>"some data","date"=>date("Y-m-s"));
      $result = $collection->save($data, array("safe" => true));
      $this->assertEquals(1, $result["ok"], json_encode($result));

      $tmp = array("date" => 1);
      $this->assertEquals(1, $tmp['date']);
      $this->assertEquals(true, $collection->ensureIndex($tmp));
      $this->assertEquals(1, $tmp['date']);

      unsetTimezone();
    }
예제 #2
0
 public function tearDown()
 {
     unsetTimezone();
 }