public function testDelete() { // insert $this->collection->batchInsert(array(array('a' => 1), array('a' => 2), array('a' => 3), array('a' => 4), array('a' => 5), array('a' => 6))); // delete $batch = new BatchDelete($this->collection); $batch->delete(array('a' => 2))->delete($this->collection->expression()->where('a', 4))->delete(function (Expression $e) { $e->where('a', 6); })->execute(); // test $result = $this->collection->findAsArray()->sort(array('a' => 1))->map(function ($data) { unset($data['_id']); return $data; }); $this->assertEquals(array_values($result), array(array('a' => 1), array('a' => 3), array('a' => 5))); }
public function testReturnAsArray() { $document = $this->collection->createDocument(array('some-field' => 'some-value')); $document->save(); // find all rows $document = $this->collection->findAsArray()->where('some-field', 'some-value')->rewind()->current(); $this->assertEquals('array', gettype($document)); // find one row $document = $this->collection->findAsArray()->where('some-field', 'some-value')->findOne(); $this->assertEquals('array', gettype($document)); }