added test for Mongo::addCondition method
This commit is contained in:
@ -333,6 +333,42 @@ class MongoModelTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame(1, $this->method_count->invoke($this->model, array('name' => 'testbread')));
|
$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()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
$conf = array('driver' => 'MongoDriver', 'hostname' => 'localhost', 'database' => 'test', 'username' => 'test', 'password' => '1234', 'port' => 27017);
|
$conf = array('driver' => 'MongoDriver', 'hostname' => 'localhost', 'database' => 'test', 'username' => 'test', 'password' => '1234', 'port' => 27017);
|
||||||
|
Reference in New Issue
Block a user