|
@ -17,7 +17,6 @@ require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; |
|
|
|
|
|
|
|
|
class DbDriverTest extends PHPUnit_Framework_TestCase |
|
|
class DbDriverTest extends PHPUnit_Framework_TestCase |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
private $driver; |
|
|
private $driver; |
|
|
|
|
|
|
|
|
public function setUp() |
|
|
public function setUp() |
|
@ -29,15 +28,18 @@ class DbDriverTest extends PHPUnit_Framework_TestCase |
|
|
public function testConstruct() |
|
|
public function testConstruct() |
|
|
{ |
|
|
{ |
|
|
$conf = array('hostname' => 'localhost', 'database' => 'db', 'username' => 'test', 'password' => '1234'); |
|
|
$conf = array('hostname' => 'localhost', 'database' => 'db', 'username' => 'test', 'password' => '1234'); |
|
|
$this->driver = $this->getMockForAbstractClass('DbDriver', array($conf)); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
$this->driver = $this->getMockForAbstractClass('DbDriver', array($conf)); |
|
|
|
|
|
} |
|
|
|
|
|
catch (GeneralException $expected) { |
|
|
|
|
|
$this->fail($expected->getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
$this->assertInstanceOf('DbDriver', $this->driver); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @expectedException GeneralException |
|
|
|
|
|
* @expectedExceptionMessage Configuration must have a "username". |
|
|
|
|
|
*/ |
|
|
|
|
|
public function testConstructWrongConfig() |
|
|
public function testConstructWrongConfig() |
|
|
{ |
|
|
{ |
|
|
|
|
|
$this->setExpectedException('GeneralException', 'Configuration must have a "username"'); |
|
|
$conf = array('hostname' => 'localhost', 'database' => 'db'); |
|
|
$conf = array('hostname' => 'localhost', 'database' => 'db'); |
|
|
$this->getMockForAbstractClass('DbDriver', array($conf)); |
|
|
$this->getMockForAbstractClass('DbDriver', array($conf)); |
|
|
} |
|
|
} |
|
@ -130,7 +132,7 @@ class DbDriverTest extends PHPUnit_Framework_TestCase |
|
|
public function testDeleteWithWHEREDbExpr() |
|
|
public function testDeleteWithWHEREDbExpr() |
|
|
{ |
|
|
{ |
|
|
$this->setDriverPrepareFunction(); |
|
|
$this->setDriverPrepareFunction(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = $this->driver->delete('users', new DbExpr('name=tony')); |
|
|
$sql = $this->driver->delete('users', new DbExpr('name=tony')); |
|
|
$this->assertEquals('DELETE FROM `users` WHERE name=tony', $sql); |
|
|
$this->assertEquals('DELETE FROM `users` WHERE name=tony', $sql); |
|
|
} |
|
|
} |
|
|