|
|
@ -44,6 +44,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->collection = $db->selectCollection($collection); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testCommandFactory() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND); |
|
|
@ -60,6 +63,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertInstanceOf('RemoveMongoCommand', $cmd); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testFindCommand() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $this->collection); |
|
|
@ -90,6 +96,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals('insert', $result['name']); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testFindCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, $this->collection); |
|
|
@ -98,6 +107,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testInsertCommand() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
@ -117,6 +129,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals(1, $result->count()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testInsertCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
@ -124,6 +139,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testUpdateCommand() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
@ -149,6 +167,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals(1, $result->count()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testUpdateCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $this->collection); |
|
|
@ -157,6 +178,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testRemoveCommand() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
@ -182,6 +206,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals(0, $result->count()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testRemoveCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $this->collection); |
|
|
@ -189,6 +216,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testCommandCommandNotAllParamsBinded() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, $this->collection); |
|
|
@ -196,6 +226,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->execute(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testCommandCommandNotMongoDb() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock()); |
|
|
@ -203,6 +236,9 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertFalse($cmd->execute()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testCommandCommand() |
|
|
|
{ |
|
|
|
$col = new CollectionMock(); |
|
|
@ -216,12 +252,18 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertTrue($cmd->execute()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testToStringParamsNotSet() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock()); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @group Mongo |
|
|
|
*/ |
|
|
|
public function testToString() |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock()); |
|
|
|