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

@ -175,6 +175,49 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
/**
* @runInSeparateProcess
*/
public function testFetchPairs()
{
if (!defined('DEBUG')) {
define('DEBUG', false);
}
$resultMock = $this->getMockBuilder('mysqli_result')
->disableOriginalConstructor()
->setMethods(array('fetch_array', 'close'))
->setMockClassName('Mysqli_Result_Mock')
->getMock();
$resultMock
->expects($this->at(0))
->method('fetch_array')
->will($this->returnValue(array('pair', 'value')));
$resultMock
->expects($this->at(1))
->method('fetch_array')
->will($this->returnValue(false));
$resultMock
->expects($this->any())
->method('close')
->will($this->returnValue(TRUE));
$mysqliMock = $this->getMock('MysqliDrvr', array('query'));
$mysqliMock
->expects($this->any())
->method('query')
->with($this->anything())
->will($this->returnValue($resultMock));
$this->driver
->expects($this->any())
->method('getConnection')
->will($this->returnValue($mysqliMock));
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertEquals(array('pair' => 'value'), $this->stmt->fetchPairs());
}
/**
* @runInSeparateProcess
*/
public function testFetchWithDebug()
{
if (!defined('DEBUG')) {