merge mongo with master
This commit is contained in:
@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/../../model/MySQLiStatement.php';
|
||||
require_once dirname(__FILE__) . '/../../model/DbDriver.php';
|
||||
require_once dirname(__FILE__) . '/../../model/SqlDbDriver.php';
|
||||
require_once dirname(__FILE__) . '/../../model/MySQLiDriver.php';
|
||||
require_once dirname(__FILE__) . '/../../exception/GeneralException.php';
|
||||
|
||||
class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
@ -25,6 +26,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
private $conf = array();
|
||||
|
||||
|
||||
|
||||
protected function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
@ -49,7 +52,9 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
$this->setPreserveGlobalState(false);
|
||||
return parent::run($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testDriver()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
@ -65,10 +70,12 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
->getTable("table");
|
||||
$this->assertTablesEqual($expectedTable, $queryTable);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $this->getConnection()->getRowCount('table'));
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $this->getConnection()->getRowCount('table'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testGetConnection()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
@ -79,22 +86,24 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
$this->assertInstanceOf('mysqli', $driver->getConnection());
|
||||
$this->assertTrue($driver->isConnected());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Unknown database
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testGetConnectionWrongConfig()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
define('DEBUG', false);
|
||||
}
|
||||
|
||||
$this->conf['database'] = 'nodb';
|
||||
$driver = new MySQLiDriver($this->conf);
|
||||
|
||||
$this->setExpectedException('GeneralException', 'Unknown database \'nodb\'');
|
||||
|
||||
$this->assertNull('mysqli', $driver->getConnection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testDisconnect()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
@ -111,7 +120,9 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
$driver->disconnect();
|
||||
$this->assertAttributeEquals(null, 'connection', $driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testInsert()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
@ -120,18 +131,19 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
$driver = new MySQLiDriver($this->conf);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $driver->getInsertId());
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => null, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(4, $driver->getInsertId());
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => null, 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(5, $driver->getInsertId());
|
||||
$this->assertEquals(2, $driver->insert('table', array('id' => '5', 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20'), array('id' => 8)));
|
||||
$this->assertEquals(8, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => null, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(4, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => null, 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(5, $driver->getInsertId());
|
||||
$this->assertSame(2, $driver->insert('table', array('id' => '5', 'user' => true, 'content' => 'some test content', 'created' => '2011-11-07 11:35:20'), array('id' => 8)));
|
||||
$this->assertSame(8, $driver->getInsertId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: DbDriver::getInsertId($table = null, $key = null) - params not used
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testGetInsertId()
|
||||
{
|
||||
@ -141,10 +153,12 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
$driver = new MySQLiDriver($this->conf);
|
||||
|
||||
$this->assertEquals(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertEquals(3, $driver->getInsertId());
|
||||
$this->assertSame(1, $driver->insert('table', array('id' => 3, 'user' => 'tony', 'content' => 'some test content', 'created' => '2011-11-07 11:35:20')));
|
||||
$this->assertSame(3, $driver->getInsertId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testTransaction()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
@ -175,7 +189,9 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase
|
||||
->getTable("table");
|
||||
$this->assertTablesEqual($expectedTable, $queryTable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group MySQL
|
||||
*/
|
||||
public function testRollback()
|
||||
{
|
||||
if (!defined('DEBUG')) {
|
||||
|
Reference in New Issue
Block a user