modified model classes with tests

This commit is contained in:
Anton Grebnev
2011-11-17 15:12:47 +04:00
parent e740ae7000
commit 7e8fe0f94d
10 changed files with 212 additions and 85 deletions

View File

@ -219,12 +219,32 @@ class MongoDriverTest extends PHPUnit_Framework_TestCase
$mongo = new MongoDriver($this->conf);
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows());
$this->assertEquals(0, $mongo->insert('items', array('name' => 'bread')));
//$this->assertNotEmpty($mongo->getInsertId());
$this->assertNotEmpty($mongo->getInsertId());
$this->assertEquals(2, $mongo->find('items', array('name' => 'bread'))->numRows());
$this->assertEquals(0, $mongo->insert('items', array('name' => 'meat', 'weight' => 230)));
$this->assertEquals(230, $mongo->get('items', array('name' => 'meat'))->fetch()->weight);
}
public function testGetInsertId()
{
if (!defined('DEBUG')) {
define('DEBUG', false);
}
$mongo = new MongoDriver($this->conf);
$this->assertEquals(0, $mongo->getInsertId());
$this->assertEquals(1, $mongo->find('items', array('name' => 'bread'))->numRows());
$this->assertEquals(0, $mongo->insert('items', array('name' => 'bread')));
$this->assertEquals(2, $mongo->find('items', array('name' => 'bread'))->numRows());
$id1 = $mongo->getInsertId();
$this->assertNotEmpty($id1);
$this->assertEquals(0, $mongo->insert('items', array('name' => 'bread')));
$id2 = $mongo->getInsertId();
$this->assertNotEmpty($id2);
$this->assertNotEquals($id1, $id2);
$this->assertEquals(3, $mongo->find('items', array('name' => 'bread'))->numRows());
}
/**
* @runInSeparateProcess
*/