blob: d5c0dea08d96b5eaf6d9c7519c1b61f82a2ffa35 [file] [log] [blame]
Taufan Aditya655a89f2012-03-29 03:00:56 +07001<?php
2
3class DB_test extends CI_TestCase {
4
Taufan Adityaa8a2e332012-03-29 03:56:46 +07005 public function test_db_invalid()
Taufan Aditya655a89f2012-03-29 03:00:56 +07006 {
Taufan Adityaee2f5d02012-03-30 06:29:11 +07007 $connection = new Mock_Database_DB(array(
Taufan Adityaa8a2e332012-03-29 03:56:46 +07008 '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 Adityaee2f5d02012-03-30 06:29:11 +070020 Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE);
Taufan Adityaa8a2e332012-03-29 03:56:46 +070021 }
22
23 // ------------------------------------------------------------------------
24
25 public function test_db_valid()
26 {
Taufan Adityaee2f5d02012-03-30 06:29:11 +070027 $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 Aditya655a89f2012-03-29 03:00:56 +070030
31 $this->assertTrue($db instanceof CI_DB);
32 $this->assertTrue($db instanceof CI_DB_Driver);
Taufan Adityaee2f5d02012-03-30 06:29:11 +070033 }
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 Aditya655a89f2012-03-29 03:00:56 +070045 }
Andrey Andreev59d6b4f2012-05-25 02:08:00 +030046
Taufan Aditya655a89f2012-03-29 03:00:56 +070047}