Move library into src folder, fix simpletest test runner
This commit is contained in:
parent
aeab1a31ec
commit
8511c6a445
21
autoload.php
21
autoload.php
@ -25,7 +25,7 @@ namespace Query;
|
|||||||
* Reference to root path
|
* Reference to root path
|
||||||
* @subpackage Core
|
* @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
|
* Path to driver classes
|
||||||
@ -39,24 +39,7 @@ require(QBASE_PATH.'common.php');
|
|||||||
// Load Query Classes
|
// Load Query Classes
|
||||||
spl_autoload_register(function ($class)
|
spl_autoload_register(function ($class)
|
||||||
{
|
{
|
||||||
/*$class_segments = explode('\\', $class);
|
// Load by namespace
|
||||||
$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
|
|
||||||
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
||||||
$file = QBASE_PATH . "{$path}.php";
|
$file = QBASE_PATH . "{$path}.php";
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ setup:
|
|||||||
PHPCI: true
|
PHPCI: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
php_unit:
|
|
||||||
config: 'phpunit.xml'
|
|
||||||
php_docblock_checker:
|
php_docblock_checker:
|
||||||
allowed_warnings: 0
|
allowed_warnings: 0
|
||||||
skip_classes: true
|
skip_classes: true
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
<template name="clean" />
|
<template name="clean" />
|
||||||
</transformations>
|
</transformations>
|
||||||
<files>
|
<files>
|
||||||
<directory>.</directory>
|
<file>autoload.php</file>
|
||||||
<directory>tests</directory>
|
<directory>src/*</directory>
|
||||||
<directory>coverage</directory>
|
|
||||||
<directory>vendor</directory>
|
|
||||||
<ignore>tests/*</ignore>
|
<ignore>tests/*</ignore>
|
||||||
<ignore>coverage/*</ignore>
|
<ignore>coverage/*</ignore>
|
||||||
<ignore>vendor/*</ignore>
|
<ignore>vendor/*</ignore>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<phpunit
|
<phpunit
|
||||||
colors="true"
|
colors="true"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
@ -33,8 +32,8 @@
|
|||||||
<file>tests/databases/firebird/FirebirdQBTest.php</file>
|
<file>tests/databases/firebird/FirebirdQBTest.php</file>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="PDOFirebirdTests">
|
<testsuite name="PDOFirebirdTests">
|
||||||
<file>tests/databases/pdo_firebird/PDOFirebirdTest.php</file>
|
<file>tests/databases/pdofirebird/PDOFirebirdTest.php</file>
|
||||||
<file>tests/databases/pdo_firebird/PDOFirebirdQBTest.php</file>
|
<file>tests/databases/pdofirebird/PDOFirebirdQBTest.php</file>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
@ -36,7 +36,7 @@ class PgSQLQBTest extends QBTest {
|
|||||||
$params->options = array();
|
$params->options = array();
|
||||||
$params->options[\PDO::ATTR_PERSISTENT] = TRUE;
|
$params->options[\PDO::ATTR_PERSISTENT] = TRUE;
|
||||||
}
|
}
|
||||||
elseif (($var = getenv('CI'))) // Travis CI Connection Info
|
elseif (getenv('CI')) // Travis CI Connection Info
|
||||||
{
|
{
|
||||||
$params = array(
|
$params = array(
|
||||||
'host' => '127.0.0.1',
|
'host' => '127.0.0.1',
|
||||||
@ -63,8 +63,11 @@ class PgSQLQBTest extends QBTest {
|
|||||||
|
|
||||||
public function testQueryExplain()
|
public function testQueryExplain()
|
||||||
{
|
{
|
||||||
$this->markTestSkipped();
|
if (getenv('CI'))
|
||||||
return;
|
{
|
||||||
|
$this->markTestSkipped("Skip this test on CI, because the check is Postgres version dependent");
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->db->select('id, key as k, val')
|
$query = $this->db->select('id, key as k, val')
|
||||||
->explain()
|
->explain()
|
||||||
->where('id >', 1)
|
->where('id >', 1)
|
||||||
@ -75,13 +78,13 @@ return;
|
|||||||
|
|
||||||
$expected = array (
|
$expected = array (
|
||||||
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 (
|
array (
|
||||||
'QUERY PLAN' => ' Output: id, key, val',
|
'QUERY PLAN' => ' Output: id, key, val',
|
||||||
),
|
),
|
||||||
array (
|
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 (
|
array (
|
||||||
'QUERY PLAN' => ' Output: id, key, val',
|
'QUERY PLAN' => ' Output: id, key, val',
|
||||||
@ -90,7 +93,7 @@ return;
|
|||||||
'QUERY PLAN' => ' Recheck Cond: ((create_test.id > 1) AND (create_test.id < 900))',
|
'QUERY PLAN' => ' Recheck Cond: ((create_test.id > 1) AND (create_test.id < 900))',
|
||||||
),
|
),
|
||||||
array (
|
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 (
|
array (
|
||||||
'QUERY PLAN' => ' Index Cond: ((create_test.id > 1) AND (create_test.id < 900))',
|
'QUERY PLAN' => ' Index Cond: ((create_test.id > 1) AND (create_test.id < 900))',
|
||||||
|
@ -39,6 +39,18 @@ require_once('/htdocs/__lib/simpletest/autorun.php');
|
|||||||
*/
|
*/
|
||||||
abstract class Query_TestCase extends UnitTestCase {
|
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
|
* Define assertInstanceOf for simpletest
|
||||||
*
|
*
|
||||||
@ -86,21 +98,6 @@ define('QDS', DIRECTORY_SEPARATOR);
|
|||||||
// Include db classes
|
// Include db classes
|
||||||
require_once(QBASE_DIR . 'autoload.php');
|
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
|
// Include db tests
|
||||||
// Load db classes based on capability
|
// Load db classes based on capability
|
||||||
$test_path = QTEST_DIR.'/databases/';
|
$test_path = QTEST_DIR.'/databases/';
|
||||||
@ -118,9 +115,11 @@ if (function_exists('fbird_connect'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$driver_test_map = array(
|
$driver_test_map = array(
|
||||||
'Firebird' => in_array('interbase', $drivers),
|
//'Firebird' => in_array('interbase', $drivers),
|
||||||
|
'MySQL' => in_array('mysql', $drivers),
|
||||||
'SQLite' => in_array('sqlite', $drivers),
|
'SQLite' => in_array('sqlite', $drivers),
|
||||||
'PgSQL' => in_array('pgsql', $drivers),
|
'PgSQL' => in_array('pgsql', $drivers),
|
||||||
|
//'PDOFirebird' => in_array('firebird', $drivers)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Determine which testcases to load
|
// Determine which testcases to load
|
||||||
@ -128,7 +127,7 @@ foreach($driver_test_map as $name => $do_load)
|
|||||||
{
|
{
|
||||||
$path = $test_path . strtolower($name) . '/';
|
$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}Test.php");
|
||||||
require_once("{$path}{$name}QBTest.php");
|
require_once("{$path}{$name}QBTest.php");
|
||||||
|
Loading…
Reference in New Issue
Block a user