|
|
@ -1,14 +1,14 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
/* |
|
|
|
* @copyright NetMonsters <team@netmonsters.ru> |
|
|
|
* @link http://netmonsters.ru |
|
|
|
* @package Majestic |
|
|
|
* @subpackage UnitTests |
|
|
|
* @since 2011-11-10 |
|
|
|
* |
|
|
|
* Unit tests for MongoDriver class |
|
|
|
*/ |
|
|
|
* @copyright NetMonsters <team@netmonsters.ru> |
|
|
|
* @link http://netmonsters.ru |
|
|
|
* @package Majestic |
|
|
|
* @subpackage UnitTests |
|
|
|
* @since 2011-11-10 |
|
|
|
* |
|
|
|
* Unit tests for MongoDriver class |
|
|
|
*/ |
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/../../model/DbDriver.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../model/NoSqlDbDriver.php'; |
|
|
@ -110,7 +110,6 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals(0, $count_result); |
|
|
|
$this->assertEquals($count_result, $find_result->count()); |
|
|
|
|
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
|
$cmd |
|
|
|
->bindParam('data', array('name' => 'insert')) |
|
|
@ -126,7 +125,6 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertEquals(2, $count_cmd->execute()); |
|
|
|
$find_cmd->bindParam('condition', array('name' => 'insert')); |
|
|
|
$this->assertEquals($find_cmd->execute()->count(), $count_cmd->execute()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -186,8 +184,6 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$cmd->bindParam('condition', array('name' => 'equal object'))->bindParam('fields', array()); |
|
|
|
$result = $cmd->execute(); |
|
|
|
$this->assertEquals(2, $result->count()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -329,24 +325,26 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COUNT, new CollectionMock()); |
|
|
|
$cmd->bindParam('condition', array()); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::FIND, new CollectionMock()); |
|
|
|
$cmd->bindParam('condition', array()); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
$this->assertContains('Condition: ' . '[]' . PHP_EOL, $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::COMMAND, new CollectionMock()); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
|
$cmd->bindParam('command', array()); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: CollectionMock', $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
|
$cmd |
|
|
|
->bindParam('data', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: ', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString()); |
|
|
|
$this->assertContains('Bulk insert: FALSE', $cmd->__toString()); |
|
|
|
$this->assertContains('Data: ' . '[' . PHP_EOL . "\tname = insert" . PHP_EOL . ']' . PHP_EOL, $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::INSERT, $this->collection); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
@ -357,14 +355,14 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->assertContains('Bulk insert: TRUE', $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd->bindParam('condition', array('name' => 'insert'))->bindParam('fields', array()); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: ', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::REMOVE, $this->collection); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
|
$cmd |
|
|
|
->bindParam('condition', array('name' => 'insert')) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: ', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString()); |
|
|
|
|
|
|
|
$cmd = MongoCommandBuilder::factory(MongoCommandBuilder::UPDATE, $this->collection); |
|
|
|
$this->assertSame('Command properties not set', $cmd->__toString()); |
|
|
@ -373,7 +371,7 @@ class MongoDbCommandTest extends PHPUnit_Framework_TestCase |
|
|
|
->bindParam('data', array('$set' => array('name' => 'update'))) |
|
|
|
->bindParam('upsert', false) |
|
|
|
->bindParam('safe', true); |
|
|
|
$this->assertStringStartsWith(PHP_EOL . 'Collection: ', $cmd->__toString()); |
|
|
|
$this->assertStringStartsWith("\n" . 'Collection: ', $cmd->__toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|