Esempio n. 1
0
 /** 
  * Test iterator's toJSON() method
  */
 public function testIteratorJSON()
 {
     TestModel::getCollection()->drop();
     $names = array('A', 'B', 'C');
     foreach ($names as $name) {
         $m = new TestModel();
         $m->name = $name;
         $m->update();
     }
     $json = TestModel::search(array(), array('name' => 1))->toJSON();
     $data = json_decode($json, true);
     $i = 0;
     foreach ($data as $row) {
         $this->assertEquals($names[$i++], $row['name']);
     }
 }