added methods to MongoDriver for custom commands, findAndModify, count

This commit is contained in:
Anton Grebnev
2011-11-22 16:29:00 +04:00
parent 54b991314d
commit a87845980d
7 changed files with 156 additions and 7 deletions

View File

@ -84,7 +84,7 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
->bindParam('condition', array('name' => 'insert'))
->bindParam('fields', array())
->bindParam('multiple', false);
$result = $cmd->execute();
$this->assertEquals('insert', $result['name']);
}
@ -199,4 +199,26 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $this->collection);
$cmd->execute();
}
/**
* @expectedException Exception
* @expectedExceptionMessage CommandMongoCommand error. Bind all required params first.
*/
public function testCommandCommandNotAllParamsBinded()
{
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, $this->collection);
$cmd->execute();
}
public function testCommandCommandNotMongoDb()
{
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock());
$cmd->bindParam('command', array());
$this->assertFalse($cmd->execute());
}
}
class CollectionMock
{
public $db = array();
}