replacement @expectedException to setExpectedException

This commit is contained in:
Vyacheslav Agafonov
2011-12-01 17:35:13 +04:00
parent c214995796
commit 66857702b6
7 changed files with 22 additions and 46 deletions

View File

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