Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexispeter committed Feb 2, 2015
1 parent 3aa3c65 commit 0f21202
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/library/CM/MongoDb/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@ public function testFind() {
$this->assertEquals([['foo' => 1], ['foo' => 1], ['foo' => 2], ['foo' => 3]], $actual);
}

public function testFindBatchSize() {
$mongoDb = CM_Service_Manager::getInstance()->getMongoDb();
$collectionName = 'findBatchSize';
CM_Config::get()->CM_MongoDb_Client->batchSize = null;

$cursor = $mongoDb->find($collectionName);
$this->assertSame(0, $cursor->info()['batchSize']);
$cursor = $mongoDb->find($collectionName, null, null, ['$match' => ['foo' => 'bar']]);
$this->assertSame(0, $cursor->info()['batchSize']);
$this->assertSame(101, $cursor->info()['query']['cursor']['batchSize']);

CM_Config::get()->CM_MongoDb_Client->batchSize = 10;

$cursor = $mongoDb->find($collectionName);
$this->assertSame(10, $cursor->info()['batchSize']);
$cursor = $mongoDb->find($collectionName, null, null, ['$match' => ['foo' => 'bar']]);
$this->assertSame(10, $cursor->info()['batchSize']);
$this->assertSame(10, $cursor->info()['query']['cursor']['batchSize']);
}

public function testFindAndModify() {
$mongoDb = CM_Service_Manager::getInstance()->getMongoDb();
$collectionName = 'findAndModify';
Expand Down

0 comments on commit 0f21202

Please sign in to comment.