summaryrefslogtreecommitdiffstats
path: root/tests/mocks/database/db.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-03-28 22:00:56 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-03-28 22:00:56 +0200
commit655a89f4059ebae017d1c4ec5f26aeb2cf4a3bae (patch)
treefe33f2f905631133d4d9807ef0f75d8d14618392 /tests/mocks/database/db.php
parent3b2587e1559d2cbe751d04f801f999ef3fa4e74c (diff)
Preliminary Database Test
Diffstat (limited to 'tests/mocks/database/db.php')
-rw-r--r--tests/mocks/database/db.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php
new file mode 100644
index 000000000..d7a6351a0
--- /dev/null
+++ b/tests/mocks/database/db.php
@@ -0,0 +1,43 @@
+<?php
+
+class Mock_Database_DB {
+
+ private $config = array();
+
+ /**
+ * Prepare database configuration skeleton
+ *
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($config = array())
+ {
+ include_once(BASEPATH.'database/DB.php');
+
+ $this->config = $config;
+ }
+
+ public function set_config($group = 'default')
+ {
+ if ( ! isset($this->config[$group]))
+ {
+ throw new InvalidArgumentException('Group '.$group.' not exists');
+ }
+
+ if ( ! empty($this->config[$group]['dsn']))
+ {
+ $dsn = $this->config[$group]['dsn'];
+ }
+ else
+ {
+ $config = $this->config[$group];
+ $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password']
+ .'@'.$config['hostname'].'/'.$config['database'];
+
+ }
+
+ $params = array_slice($this->config[$group], 6);
+
+ return $dsn.http_build_query($params);
+ }
+} \ No newline at end of file