modified tests for new DbDriver hierarchy
This commit is contained in:
@ -43,68 +43,7 @@ class DbStatementTest extends PHPUnit_Framework_TestCase
|
||||
public function testConstruct()
|
||||
{
|
||||
$this->assertAttributeEquals($this->driver, 'driver', $this->stmt);
|
||||
$this->assertAttributeEquals($this->sql, 'sql', $this->stmt);
|
||||
}
|
||||
|
||||
public function testBindParam()
|
||||
{
|
||||
$val = $this->getMockBuilder('DbExpr')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->assertFalse($this->stmt->bindParam('var', $val));
|
||||
$this->assertTrue($this->stmt->bindParam('place', $val));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Placeholder must be an array or string
|
||||
* @TODO: change Exception Message 'Placeholder must be an array or string' - no arrays available
|
||||
*/
|
||||
public function testBindParamExceptionParam()
|
||||
{
|
||||
$val = 1;
|
||||
$this->stmt->bindParam(array(), $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Objects excepts DbExpr not allowed.
|
||||
*/
|
||||
public function testBindParamExceptionWrongObject()
|
||||
{
|
||||
$val = $this->getMock('NotDbExpr');
|
||||
$this->stmt->bindParam('paa', $val);
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$this->stmt
|
||||
->expects($this->once())
|
||||
->method('driverExecute')
|
||||
->with($this->anything())
|
||||
->will($this->returnCallback(array($this, 'dbStatementAssemble')));
|
||||
|
||||
$this->driver
|
||||
->expects($this->any())
|
||||
->method('quote')
|
||||
->with($this->anything())
|
||||
->will($this->returnCallback(array($this, 'driverQuote')));
|
||||
|
||||
$result = $this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
|
||||
$this->assertEquals('SELECT * place_val FROM place_val AND new_val', $result);
|
||||
}
|
||||
|
||||
public function testExecuteNoPlaceholders()
|
||||
{
|
||||
$this->sql = 'PLAIN SQL';
|
||||
$this->stmt = $this->getMockForAbstractClass('DbStatement', array($this->driver, $this->sql));
|
||||
$this->stmt
|
||||
->expects($this->once())
|
||||
->method('driverExecute')
|
||||
->with($this->anything())
|
||||
->will($this->returnCallback(array($this, 'dbStatementAssemble')));
|
||||
$result = $this->stmt->execute(array());
|
||||
$this->assertEquals('PLAIN SQL', $result);
|
||||
$this->assertAttributeEquals($this->sql, 'request', $this->stmt);
|
||||
}
|
||||
|
||||
public function testFetch()
|
||||
@ -131,16 +70,6 @@ class DbStatementTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(31, $result['one']);
|
||||
}
|
||||
|
||||
public function dbStatementAssemble($val)
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function driverQuote($val)
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function dbStatementFetch($style)
|
||||
{
|
||||
$result = null;
|
||||
|
Reference in New Issue
Block a user