merge mongo with master

This commit is contained in:
Anton Grebnev
2011-12-05 20:11:20 +04:00
72 changed files with 575 additions and 441 deletions

View File

@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/../../model/Db.php';
require_once dirname(__FILE__) . '/../../model/DbDriver.php';
require_once dirname(__FILE__) . '/../../model/DbStatement.php';
require_once dirname(__FILE__) . '/../../model/MySQLiStatement.php';
require_once dirname(__FILE__) . '/../../exception/GeneralException.php';
class MySQLiStatementTest extends PHPUnit_Framework_TestCase
{
@ -120,6 +121,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
/**
* @runInSeparateProcess
* @group MySQL
*/
public function testFetchNoResult()
{
@ -131,8 +133,7 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
/**
* @runInSeparateProcess
* @expectedException Exception
* @expectedExceptionMessage ERROR
* @group MySQL
*/
public function testDriverExecuteNoResult()
{
@ -140,11 +141,13 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
define('DEBUG', false);
}
$this->setDriverGetConnectionWrongResultMethod();
$this->setExpectedException('GeneralException', 'ERROR');
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
}
/**
* @runInSeparateProcess
* @group MySQL
*/
public function testFetch()
{
@ -153,14 +156,15 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
}
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertEquals('OBJECT', $this->stmt->fetch());
$this->assertEquals('ARRAY', $this->stmt->fetch(Db::FETCH_NUM));
$this->assertEquals('ASSOC', $this->stmt->fetch(Db::FETCH_ASSOC));
$this->assertEquals('ARRAY', $this->stmt->fetch(Db::FETCH_BOTH));
$this->assertSame('OBJECT', $this->stmt->fetch());
$this->assertSame('ARRAY', $this->stmt->fetch(Db::FETCH_NUM));
$this->assertSame('ASSOC', $this->stmt->fetch(Db::FETCH_ASSOC));
$this->assertSame('ARRAY', $this->stmt->fetch(Db::FETCH_BOTH));
}
/**
* @runInSeparateProcess
* @group MySQL
*/
public function testFetchObject()
{
@ -169,11 +173,12 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
}
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertEquals('OBJECT', $this->stmt->fetchObject());
$this->assertSame('OBJECT', $this->stmt->fetchObject());
}
/**
* @runInSeparateProcess
* @group MySQL
*/
public function testFetchPairs()
{
@ -225,11 +230,12 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
}
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertEquals('OBJECT', $this->stmt->fetch());
$this->assertSame('OBJECT', $this->stmt->fetch());
}
/**
* @runInSeparateProcess
* @group MySQL
*/
public function testClose()
{
@ -244,6 +250,9 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
$this->assertAttributeEquals(null, 'result', $this->stmt);
}
/**
* @group MySQL
*/
public function testAffectedRows()
{
$mysqliMock = $this->getMockBuilder('MysqliDrvr');
@ -254,9 +263,12 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
->method('getConnection')
->will($this->returnValue($mysqliMock));
$this->assertEquals('AFFECTED_ROWS', $this->stmt->affectedRows());
$this->assertSame('AFFECTED_ROWS', $this->stmt->affectedRows());
}
/**
* @group MySQL
*/
public function testNumRowsNoResult()
{
$this->assertFalse($this->stmt->numRows());
@ -264,24 +276,23 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
/**
* @runInSeparateProcess
* @expectedException Exception
* @TODO: exception just for code coverage - could not mock mysqli properties
* @group MySQL
*/
public function testNumRows()
{
$this->markTestSkipped('Unable to execute a method or access a property of an incomplete object.');
if (!defined('DEBUG')) {
define('DEBUG', false);
}
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->assertNull($this->stmt->numRows());
}
/**
* @expectedException Exception
* @expectedExceptionMessage Invalid fetch mode
* @runInSeparateProcess
* @group MySQL
*/
public function testFetchInvalidMode()
{
@ -290,6 +301,9 @@ class MySQLiStatementTest extends PHPUnit_Framework_TestCase
}
$this->setDriverGetConnectionMethod();
$this->stmt->execute(array('place' => 'place_val', 'new' => 'new_val'));
$this->setExpectedException('GeneralException');
$this->stmt->fetch(324);
}