Browse Source

added test for Mongo::addCondition method

namespace
Anton Grebnev 12 years ago
parent
commit
98324588b7
  1. 36
      tests/model/MongoModelTest.php

36
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);

Loading…
Cancel
Save