Taufan Aditya | f4c6c9b | 2012-04-04 23:24:09 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class Mock_Database_DB_Driver extends CI_DB_driver { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame^] | 4 | |
Taufan Aditya | f4c6c9b | 2012-04-04 23:24:09 +0700 | [diff] [blame] | 5 | /** |
| 6 | * @var object The actual Driver |
| 7 | */ |
| 8 | protected $ci_db_driver; |
| 9 | |
| 10 | /** |
| 11 | * Instantiate the database driver |
| 12 | * |
| 13 | * @param string DB Driver class name |
| 14 | * @param array DB configuration to set |
| 15 | * @return void |
| 16 | */ |
| 17 | public function __construct($driver_class, $config = array()) |
| 18 | { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame^] | 19 | if (is_string($driver_class)) |
| 20 | { |
| 21 | $this->ci_db_driver = new $driver_class($config); |
| 22 | } |
Taufan Aditya | f4c6c9b | 2012-04-04 23:24:09 +0700 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Overloading method, emulate the actual driver method (multiple inheritance workaround) |
| 27 | */ |
| 28 | public function __call($method, $arguments) |
| 29 | { |
| 30 | if ( ! is_callable(array($this->ci_db_driver, $method))) |
| 31 | { |
| 32 | throw new BadMethodCallException($method. ' not exists or not implemented'); |
| 33 | } |
| 34 | |
| 35 | return call_user_func_array(array($this->ci_db_driver, $method), $arguments); |
| 36 | } |
| 37 | } |
| 38 | |
Taufan Aditya | 61ff054 | 2012-04-05 01:23:56 +0700 | [diff] [blame] | 39 | class CI_DB extends Mock_Database_DB_QueryBuilder {} |