Taufan Aditya | 655a89f | 2012-03-29 03:00:56 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class DB_test extends CI_TestCase { |
| 4 | |
Taufan Aditya | a8a2e33 | 2012-03-29 03:56:46 +0700 | [diff] [blame] | 5 | public function test_db_invalid() |
Taufan Aditya | 655a89f | 2012-03-29 03:00:56 +0700 | [diff] [blame] | 6 | { |
Taufan Aditya | ee2f5d0 | 2012-03-30 06:29:11 +0700 | [diff] [blame] | 7 | $connection = new Mock_Database_DB(array( |
Taufan Aditya | a8a2e33 | 2012-03-29 03:56:46 +0700 | [diff] [blame] | 8 | 'undefined' => array( |
| 9 | 'dsn' => '', |
| 10 | 'hostname' => 'undefined', |
| 11 | 'username' => 'undefined', |
| 12 | 'password' => 'undefined', |
| 13 | 'database' => 'undefined', |
| 14 | 'dbdriver' => 'undefined', |
| 15 | ), |
| 16 | )); |
| 17 | |
| 18 | $this->setExpectedException('InvalidArgumentException', 'CI Error: Invalid DB driver'); |
| 19 | |
Taufan Aditya | ee2f5d0 | 2012-03-30 06:29:11 +0700 | [diff] [blame] | 20 | Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE); |
Taufan Aditya | a8a2e33 | 2012-03-29 03:56:46 +0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | // ------------------------------------------------------------------------ |
| 24 | |
| 25 | public function test_db_valid() |
| 26 | { |
Taufan Aditya | ee2f5d0 | 2012-03-30 06:29:11 +0700 | [diff] [blame] | 27 | $config = Mock_Database_DB::config(DB_DRIVER); |
| 28 | $connection = new Mock_Database_DB($config); |
| 29 | $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE); |
Taufan Aditya | 655a89f | 2012-03-29 03:00:56 +0700 | [diff] [blame] | 30 | |
| 31 | $this->assertTrue($db instanceof CI_DB); |
| 32 | $this->assertTrue($db instanceof CI_DB_Driver); |
Taufan Aditya | ee2f5d0 | 2012-03-30 06:29:11 +0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | // ------------------------------------------------------------------------ |
| 36 | |
| 37 | public function test_db_failover() |
| 38 | { |
| 39 | $config = Mock_Database_DB::config(DB_DRIVER); |
| 40 | $connection = new Mock_Database_DB($config); |
| 41 | $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE); |
| 42 | |
| 43 | $this->assertTrue($db instanceof CI_DB); |
| 44 | $this->assertTrue($db instanceof CI_DB_Driver); |
Taufan Aditya | 655a89f | 2012-03-29 03:00:56 +0700 | [diff] [blame] | 45 | } |
Andrey Andreev | 59d6b4f | 2012-05-25 02:08:00 +0300 | [diff] [blame] | 46 | |
Taufan Aditya | 655a89f | 2012-03-29 03:00:56 +0700 | [diff] [blame] | 47 | } |