From 655a89f4059ebae017d1c4ec5f26aeb2cf4a3bae Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 29 Mar 2012 03:00:56 +0700 Subject: Preliminary Database Test --- tests/mocks/database/.gitkeep | 0 tests/mocks/database/db.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) delete mode 100644 tests/mocks/database/.gitkeep create mode 100644 tests/mocks/database/db.php (limited to 'tests/mocks') diff --git a/tests/mocks/database/.gitkeep b/tests/mocks/database/.gitkeep deleted file mode 100644 index e69de29bb..000000000 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 @@ +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 -- cgit v1.2.3-24-g4f1b