diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-03-30 01:29:11 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-03-30 01:29:11 +0200 |
commit | ee2f5d08c64d96b7abc7195bcd1b6a3fd67b5b42 (patch) | |
tree | 133e61f62e6213361713b8ff9b1690afb9daded2 /tests/codeigniter/database | |
parent | dba9437218a5d8bedb75464b943e8f920d220a25 (diff) |
Multi database setup
Diffstat (limited to 'tests/codeigniter/database')
-rw-r--r-- | tests/codeigniter/database/DB_test.php | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php index 10e8dec64..9b93e223d 100644 --- a/tests/codeigniter/database/DB_test.php +++ b/tests/codeigniter/database/DB_test.php @@ -6,7 +6,7 @@ class DB_test extends CI_TestCase { public function test_db_invalid() { - $db_config = new Mock_Database_DB(array( + $connection = new Mock_Database_DB(array( 'undefined' => array( 'dsn' => '', 'hostname' => 'undefined', @@ -19,29 +19,31 @@ class DB_test extends CI_TestCase { $this->setExpectedException('InvalidArgumentException', 'CI Error: Invalid DB driver'); - Mock_Database_DB::DB($db_config->set_dsn('undefined'), TRUE); + Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE); } // ------------------------------------------------------------------------ public function test_db_valid() { - $db_config = new Mock_Database_DB(array( - 'mysql' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'mysql', - ), - )); + $config = Mock_Database_DB::config(DB_DRIVER); + $connection = new Mock_Database_DB($config); + $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE); + + $this->assertTrue($db instanceof CI_DB); + $this->assertTrue($db instanceof CI_DB_Driver); + } - $db = Mock_Database_DB::DB($db_config->set_dsn('mysql'), TRUE); + // ------------------------------------------------------------------------ + + public function test_db_failover() + { + $config = Mock_Database_DB::config(DB_DRIVER); + $connection = new Mock_Database_DB($config); + $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE); $this->assertTrue($db instanceof CI_DB); $this->assertTrue($db instanceof CI_DB_Driver); - $this->assertTrue($db instanceof CI_DB_mysql_driver); } }
\ No newline at end of file |