Model classes DbExpr, DbStatement, DbDriver and Db tested

This commit is contained in:
Anton Grebnev
2011-11-03 16:52:33 +04:00
parent 8d5885b229
commit 183b64fd37
4 changed files with 374 additions and 4 deletions

View File

@ -12,6 +12,7 @@
require_once dirname(__FILE__) . '/../../Registry.php';
require_once dirname(__FILE__) . '/../../Config.php';
require_once dirname(__FILE__) . '/../../model/DbDriver.php';
require_once dirname(__FILE__) . '/../../model/Db.php';
class DbTest extends PHPUnit_Framework_TestCase
@ -35,15 +36,17 @@ class DbTest extends PHPUnit_Framework_TestCase
public function testConnectGlobalConfig()
{
$this->getMock('DbDriver', array(), array(), 'MySQLiDriverGlobalConfMock');
Config::set('Db', array('global' =>array('hostname' => 'localhost', 'driver' => 'MySQLiDriverGlobalConfMock')));
$conf = array('hostname' => 'localhost', 'driver' => 'MySQLiDriverGlobalConfMock', 'database' => 'db', 'username' => 'test', 'password' => '1234');
$this->getMockForAbstractClass('DbDriver', array(), 'MySQLiDriverGlobalConfMock', false);
Config::set('Db', array('global' =>$conf));
Db::connect('global');
}
public function testConnectWithConfigParam()
{
$this->getMock('DbDriver', array(), array(), 'MySQLiDriverMock');
$driver = Db::connect('mysql', array('hostname' => 'localhost', 'driver' => 'MySQLiDriverMock'));
$conf = array('hostname' => 'localhost', 'driver' => 'MySQLiDriverMock', 'database' => 'db', 'username' => 'test', 'password' => '1234');
$this->getMockForAbstractClass('DbDriver', array(), 'MySQLiDriverMock', false);
$driver = Db::connect('mysql', $conf);
$this->assertInstanceOf('DbDriver', $driver);
}
/**