blob: 9bf5231e3c89c90aab6c45e46a93ce9bc8e7b0ec [file] [log] [blame]
Taufan Adityaf4c6c9b2012-04-04 23:24:09 +07001<?php
2
3class Mock_Database_DB_Driver extends CI_DB_driver {
4
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 {
19 if (is_string($driver_class)) $this->ci_db_driver = new $driver_class($config);
20 }
21
22 /**
23 * Overloading method, emulate the actual driver method (multiple inheritance workaround)
24 */
25 public function __call($method, $arguments)
26 {
27 if ( ! is_callable(array($this->ci_db_driver, $method)))
28 {
29 throw new BadMethodCallException($method. ' not exists or not implemented');
30 }
31
32 return call_user_func_array(array($this->ci_db_driver, $method), $arguments);
33 }
34}
35
36class CI_DB extends CI_DB_Driver {}