|
|
@ -59,8 +59,8 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testFindCommand() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'bread'))->bindParam('fields', array()); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'bread'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(0, $result->count()); |
|
|
|
} |
|
|
@ -72,22 +72,22 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testFindCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'bread')); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'bread')); |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
public function testInsertCommand() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT); |
|
|
|
$cmd->bindParam('collection', $collection) |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $collection); |
|
|
|
$cmd |
|
|
|
->bindParam('data', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertArrayHasKey('n', $cmd->execute()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(1, $result->count()); |
|
|
|
} |
|
|
@ -99,33 +99,33 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testInsertCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('data', array('name' => 'bread')); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $collection); |
|
|
|
$cmd->bindParam('data', array('name' => 'bread')); |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
public function testUpdateCommand() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT); |
|
|
|
$cmd->bindParam('collection', $collection) |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $collection); |
|
|
|
$cmd |
|
|
|
->bindParam('data', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertArrayHasKey('n', $cmd->execute()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE); |
|
|
|
$cmd->bindParam('collection', $collection) |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $collection); |
|
|
|
$cmd |
|
|
|
->bindParam('condition', array('name' => 'insert')) |
|
|
|
->bindParam('data', array('$set' => array('name' => 'update'))) |
|
|
|
->bindParam('upsert', false) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertArrayHasKey('n', $cmd->execute()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(0, $result->count()); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'update'))->bindParam('fields', array()); |
|
|
|
$cmd->bindParam('condition', array('name' => 'update'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(1, $result->count()); |
|
|
|
} |
|
|
@ -137,33 +137,33 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testUpdateCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('data', array('name' => 'bread')); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $collection); |
|
|
|
$cmd->bindParam('data', array('name' => 'bread')); |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
public function testRemoveCommand() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT); |
|
|
|
$cmd->bindParam('collection', $collection) |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $collection); |
|
|
|
$cmd |
|
|
|
->bindParam('data', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertArrayHasKey('n', $cmd->execute()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(1, $result->count()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE); |
|
|
|
$cmd->bindParam('collection', $collection) |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $collection); |
|
|
|
$cmd |
|
|
|
->bindParam('condition', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertArrayHasKey('n', $cmd->execute()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
|
$cmd->bindParam('collection', $collection)->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $collection); |
|
|
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(0, $result->count()); |
|
|
|
} |
|
|
@ -175,8 +175,7 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testRemoveCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$collection = $this->driver->getCollection('items'); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE); |
|
|
|
$cmd->bindParam('collection', $collection); |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $collection); |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|