From 98324588b7752f505e0270e3c6090ebfa3d5839d Mon Sep 17 00:00:00 2001 From: Anton Grebnev Date: Tue, 11 Dec 2012 18:39:26 +0400 Subject: [PATCH] added test for Mongo::addCondition method --- tests/model/MongoModelTest.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/model/MongoModelTest.php b/tests/model/MongoModelTest.php index 9f3abb0..90e5bfc 100644 --- a/tests/model/MongoModelTest.php +++ b/tests/model/MongoModelTest.php @@ -333,6 +333,42 @@ class MongoModelTest extends PHPUnit_Framework_TestCase $this->assertSame(1, $this->method_count->invoke($this->model, array('name' => 'testbread'))); } + /** + * @runInSeparateProcess + * @group Mongo + */ + public function testAddCondition() + { + Config::set('DEBUG', false); + + $model = new ReflectionClass('MongoModel'); + $method = $model->getMethod('addCondition'); + $method->setAccessible(true); + + $query = array(); + $result = $method->invokeArgs($this->model, array(&$query, 'name', 'tony')); + $this->assertSame(array('name' => 'tony'), $query); + $this->assertSame($this->model, $result); + } + + /** + * @runInSeparateProcess + * @group Mongo + */ + public function testAddConditionEmptyValue() + { + Config::set('DEBUG', false); + + $model = new ReflectionClass('MongoModel'); + $method = $model->getMethod('addCondition'); + $method->setAccessible(true); + + $query = array(); + $method->invokeArgs($this->model, array(&$query, 'name', false)); + $this->assertEmpty($query); + $method->invokeArgs($this->model, array(&$query, 'name', null)); + $this->assertEmpty($query); + } public function tearDown() { $conf = array('driver' => 'MongoDriver', 'hostname' => 'localhost', 'database' => 'test', 'username' => 'test', 'password' => '1234', 'port' => 27017);