diff --git a/classes/connection_manager.php b/classes/connection_manager.php index b4c09b8..01f4a7f 100644 --- a/classes/connection_manager.php +++ b/classes/connection_manager.php @@ -48,6 +48,7 @@ final class Connection_Manager { /** * Private constructor to prevent multiple instances + * @codeCoverageIgnore */ private function __construct() {} @@ -55,6 +56,7 @@ final class Connection_Manager { /** * Private clone method to prevent cloning + * @codeCoverageIgnore */ private function __clone() {} @@ -62,6 +64,7 @@ final class Connection_Manager { /** * Make sure serialize/deseriaze doesn't work + * @codeCoverageIgnore * @throws DomainException */ private function __wakeup() @@ -80,10 +83,12 @@ final class Connection_Manager { public static function get_instance() { + // @codeCoverageIgnoreStart if (self::$instance === null) { self::$instance = new self(); } + // @codeCoverageIgnoreEnd return self::$instance; } @@ -212,12 +217,15 @@ final class Connection_Manager { */ private function create_dsn($dbtype, $params) { + // Add the driver type to the dsn + $dsn = ($dbtype !== 'firebird' && $dbtype !== 'sqlite') + ? strtolower($dbtype).':' + : ''; + if ($dbtype === 'firebird') $dsn = "{$params->host}:{$params->file}"; elseif ($dbtype === 'sqlite') $dsn = $params->file; else { - $dsn = strtolower($dbtype) . ':'; - if ( ! empty($params->database)) { $dsn .= "dbname={$params->database}"; diff --git a/common.php b/common.php index 5a80b79..7958455 100644 --- a/common.php +++ b/common.php @@ -5,6 +5,7 @@ * Free Query Builder / Database Abstraction Layer * * @package Query + * @subpackage Core * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query @@ -15,8 +16,6 @@ /** * Global functions that don't really fit anywhere else - * - * @package Query */ // -------------------------------------------------------------------------- @@ -27,7 +26,6 @@ if ( ! function_exists('do_include')) * Bulk directory loading workaround for use * with array_map and glob * - * @subpackage Core * @param string $path * @return void */ @@ -44,7 +42,6 @@ if ( ! function_exists('mb_trim')) /** * Multibyte-safe trim function * - * @subpackage Core * @param string $string * @return string */ @@ -59,7 +56,6 @@ if ( ! function_exists('mb_trim')) /** * Filter out db rows into one array * - * @subpackage Core * @param array $array * @param mixed $index * @return array @@ -81,7 +77,6 @@ function db_filter($array, $index) /** * Connection function * - * @subpackage Core * @param mixed $params * @return Query_Builder */ @@ -99,7 +94,7 @@ function Query($params = '') // Otherwise, return a new connection return $cmanager->connect($params); } - +// @codeCoverageIgnoreStart } - +// @codeCoverageIgnoreEnd // End of common.php \ No newline at end of file diff --git a/tests/databases/pgsql/PgSQLQBTest.php b/tests/databases/pgsql/PgSQLQBTest.php index 3f33fed..bf6a1a2 100644 --- a/tests/databases/pgsql/PgSQLQBTest.php +++ b/tests/databases/pgsql/PgSQLQBTest.php @@ -24,7 +24,7 @@ class PgSQLQBTest extends QBTest { { $this->markTestSkipped("Postgres extension for PDO not loaded"); } - + // Attempt to connect, if there is a test config file if (is_file(QTEST_DIR . "/settings.json")) { @@ -57,9 +57,9 @@ class PgSQLQBTest extends QBTest { { $this->assertTrue(in_array('pgsql', PDO::getAvailableDrivers())); } - + // -------------------------------------------------------------------------- - + public function testQueryExplain() { $query = $this->db->select('id, key as k, val') @@ -67,9 +67,9 @@ class PgSQLQBTest extends QBTest { ->where('id >', 1) ->where('id <', 900) ->get('create_test', 2, 1); - + $res = $query->fetchAll(PDO::FETCH_ASSOC); - + $expected = array ( array ( 'QUERY PLAN' => 'Limit (cost=6.41..10.64 rows=2 width=68)', @@ -93,7 +93,12 @@ class PgSQLQBTest extends QBTest { 'QUERY PLAN' => ' Index Cond: ((create_test.id > 1) AND (create_test.id < 900))', ), ); - + $this->assertEqual($expected, $res); } + + public function testBackupStructure() + { + $this->assertEquals('', $this->db->util->backup_structure()); + } } \ No newline at end of file