Move library into src folder, fix simpletest test runner

This commit is contained in:
Timothy Warren 2015-07-29 16:51:17 -04:00
parent aeab1a31ec
commit 8511c6a445
36 changed files with 31 additions and 51 deletions

View File

@ -25,7 +25,7 @@ namespace Query;
* Reference to root path
* @subpackage Core
*/
if ( ! defined('QBASE_PATH')) define('QBASE_PATH', dirname(__FILE__).'/');
if ( ! defined('QBASE_PATH')) define('QBASE_PATH', dirname(__FILE__).'/src/');
/**
* Path to driver classes
@ -39,24 +39,7 @@ require(QBASE_PATH.'common.php');
// Load Query Classes
spl_autoload_register(function ($class)
{
/*$class_segments = explode('\\', $class);
$driver_class = strtolower(array_pop($class_segments));
// Load DB Driver classes
$driver_path = QDRIVER_PATH . "{$driver_class}";
if ($class_segments == array('Query', 'Driver') && is_dir($driver_path))
{
// Firebird is a special case, since it's not a PDO driver
// @codeCoverageIgnoreStart
if (function_exists('\\fbird_connect') && $driver_class === 'firebird')
{
array_map('\\do_include', glob("{$driver_path}/*.php"));
}
// @codeCoverageIgnoreEnd
}*/
// Load other classes
// Load by namespace
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = QBASE_PATH . "{$path}.php";

View File

@ -8,8 +8,6 @@ setup:
PHPCI: true
test:
php_unit:
config: 'phpunit.xml'
php_docblock_checker:
allowed_warnings: 0
skip_classes: true

View File

@ -11,10 +11,8 @@
<template name="clean" />
</transformations>
<files>
<directory>.</directory>
<directory>tests</directory>
<directory>coverage</directory>
<directory>vendor</directory>
<file>autoload.php</file>
<directory>src/*</directory>
<ignore>tests/*</ignore>
<ignore>coverage/*</ignore>
<ignore>vendor/*</ignore>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
@ -33,8 +32,8 @@
<file>tests/databases/firebird/FirebirdQBTest.php</file>
</testsuite>
<testsuite name="PDOFirebirdTests">
<file>tests/databases/pdo_firebird/PDOFirebirdTest.php</file>
<file>tests/databases/pdo_firebird/PDOFirebirdQBTest.php</file>
<file>tests/databases/pdofirebird/PDOFirebirdTest.php</file>
<file>tests/databases/pdofirebird/PDOFirebirdQBTest.php</file>
</testsuite>
</testsuites>
</phpunit>

View File

@ -36,7 +36,7 @@ class PgSQLQBTest extends QBTest {
$params->options = array();
$params->options[\PDO::ATTR_PERSISTENT] = TRUE;
}
elseif (($var = getenv('CI'))) // Travis CI Connection Info
elseif (getenv('CI')) // Travis CI Connection Info
{
$params = array(
'host' => '127.0.0.1',
@ -63,8 +63,11 @@ class PgSQLQBTest extends QBTest {
public function testQueryExplain()
{
$this->markTestSkipped();
return;
if (getenv('CI'))
{
$this->markTestSkipped("Skip this test on CI, because the check is Postgres version dependent");
}
$query = $this->db->select('id, key as k, val')
->explain()
->where('id >', 1)
@ -75,13 +78,13 @@ return;
$expected = array (
array (
'QUERY PLAN' => 'Limit (cost=6.41..10.64 rows=2 width=68)',
'QUERY PLAN' => 'Limit (cost=6.31..10.54 rows=2 width=68)',
),
array (
'QUERY PLAN' => ' Output: id, key, val',
),
array (
'QUERY PLAN' => ' -> Bitmap Heap Scan on public.create_test (cost=4.29..12.76 rows=4 width=68)',
'QUERY PLAN' => ' -> Bitmap Heap Scan on public.create_test (cost=4.19..12.66 rows=4 width=68)',
),
array (
'QUERY PLAN' => ' Output: id, key, val',
@ -90,7 +93,7 @@ return;
'QUERY PLAN' => ' Recheck Cond: ((create_test.id > 1) AND (create_test.id < 900))',
),
array (
'QUERY PLAN' => ' -> Bitmap Index Scan on create_test_pkey (cost=0.00..4.29 rows=4 width=0)',
'QUERY PLAN' => ' -> Bitmap Index Scan on create_test_pkey (cost=0.00..4.19 rows=4 width=0)',
),
array (
'QUERY PLAN' => ' Index Cond: ((create_test.id > 1) AND (create_test.id < 900))',

View File

@ -39,6 +39,18 @@ require_once('/htdocs/__lib/simpletest/autorun.php');
*/
abstract class Query_TestCase extends UnitTestCase {
public function __construct()
{
$class = get_class($this);
if (method_exists($class, 'setupBeforeClass'))
{
$class::setupBeforeClass();
}
parent::__construct();
}
/**
* Define assertInstanceOf for simpletest
*
@ -86,21 +98,6 @@ define('QDS', DIRECTORY_SEPARATOR);
// Include db classes
require_once(QBASE_DIR . 'autoload.php');
// Preset SQLite connection, so there aren't locking issues
$params = array(
'type' => 'sqlite',
'file' => ':memory:',
'host' => 'localhost',
'prefix' => 'create_',
'alias' => 'test_sqlite',
'options' => array(
PDO::ATTR_PERSISTENT => TRUE
)
);
Query($params);
unset($params);
// Include db tests
// Load db classes based on capability
$test_path = QTEST_DIR.'/databases/';
@ -118,9 +115,11 @@ if (function_exists('fbird_connect'))
}
$driver_test_map = array(
'Firebird' => in_array('interbase', $drivers),
//'Firebird' => in_array('interbase', $drivers),
'MySQL' => in_array('mysql', $drivers),
'SQLite' => in_array('sqlite', $drivers),
'PgSQL' => in_array('pgsql', $drivers),
//'PDOFirebird' => in_array('firebird', $drivers)
);
// Determine which testcases to load
@ -128,7 +127,7 @@ foreach($driver_test_map as $name => $do_load)
{
$path = $test_path . strtolower($name) . '/';
if ($do_load && ($name != 'SQLite' && ! IS_QUERCUS))
if ($do_load && (! IS_QUERCUS))
{
require_once("{$path}{$name}Test.php");
require_once("{$path}{$name}QBTest.php");