Improve code coverage on a few stupid spots
This commit is contained in:
parent
235f93bdc4
commit
a04b8b44ff
@ -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}";
|
||||
|
11
common.php
11
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
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user