diff --git a/tests/model/MySQLiDriverTest.php b/tests/model/MySQLiDriverTest.php index 878ded8..b9c9acb 100644 --- a/tests/model/MySQLiDriverTest.php +++ b/tests/model/MySQLiDriverTest.php @@ -22,6 +22,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase private $conn = null; + private $conf = array(); + protected function getConnection() { if ($this->conn === null) { @@ -31,6 +33,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase $this->conn = $this->createDefaultDBConnection(self::$pdo, $GLOBALS['DB_DBNAME']); } + $this->conf = array('hostname' => 'localhost', 'database' => $GLOBALS['DB_DBNAME'], 'username' => $GLOBALS['DB_USER'], 'password' => $GLOBALS['DB_PASSWD']); + return $this->conn; } @@ -51,8 +55,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $driver = new MySQLiDriver($this->conf); $queryTable = $this->getConnection()->createQueryTable( 'table', 'SELECT * FROM `table`' @@ -71,8 +74,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $driver = new MySQLiDriver($this->conf); $this->assertInstanceOf('mysqli', $driver->getConnection()); $this->assertTrue($driver->isConnected()); } @@ -98,8 +100,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $driver = new MySQLiDriver($this->conf); $driver->disconnect(); $this->assertAttributeEquals(null, 'connection', $driver); @@ -116,8 +117,8 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $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'))); @@ -137,8 +138,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $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()); @@ -150,8 +150,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $driver = new MySQLiDriver($this->conf); $queryTable = $this->getConnection()->createQueryTable( 'table', 'SELECT * FROM `table`' @@ -182,8 +181,7 @@ class MySQLiDriverTest extends PHPUnit_Extensions_Database_TestCase define('DEBUG', false); } - $conf = array('hostname' => 'localhost', 'database' => 'testdb', 'username' => 'root', 'password' => '1234'); - $driver = new MySQLiDriver($conf); + $driver = new MySQLiDriver($this->conf); $queryTable = $this->getConnection()->createQueryTable( 'table', 'SELECT * FROM `table`'