2014-06-09 17:02:14 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012 - 2013
|
|
|
|
* @link https://github.com/aviat4ion/Query
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Quercus detection for workarounds
|
|
|
|
*/
|
|
|
|
if ( ! defined('IS_QUERCUS'))
|
|
|
|
{
|
|
|
|
if ( ! isset($_SERVER_SOFTWARE))
|
|
|
|
{
|
|
|
|
define('IS_QUERCUS', FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$test = strpos($_SERVER["SERVER_SOFTWARE"],'Quercus') !== FALSE;
|
|
|
|
define('IS_QUERCUS', $test);
|
|
|
|
unset($test);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Include simpletest
|
|
|
|
// it has to be in the tests folder
|
2015-07-30 16:40:30 -04:00
|
|
|
require_once('simpletest/autorun.php');
|
2014-06-09 17:02:14 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for TestCases
|
|
|
|
*/
|
2014-06-30 11:01:44 -04:00
|
|
|
abstract class Query_TestCase extends UnitTestCase {
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2015-07-29 16:51:17 -04:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$class = get_class($this);
|
|
|
|
|
|
|
|
if (method_exists($class, 'setupBeforeClass'))
|
|
|
|
{
|
|
|
|
$class::setupBeforeClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
2015-07-30 16:40:30 -04:00
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
$class = get_class($this);
|
|
|
|
|
|
|
|
if (method_exists($class, 'tearDownAfterClass'))
|
|
|
|
{
|
|
|
|
$class::tearDownAfterClass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-09 17:02:14 -04:00
|
|
|
/**
|
|
|
|
* Define assertInstanceOf for simpletest
|
|
|
|
*
|
|
|
|
* @param $expected
|
|
|
|
* @param $actual
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertInstanceOf($expected, $actual, $message = '')
|
|
|
|
{
|
|
|
|
$this->assertIsA($actual, $expected, $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias to assertEqual
|
|
|
|
*
|
|
|
|
* @param mixed $expected
|
|
|
|
* @param mixed $actual
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertEquals($expected, $actual, $message = '')
|
|
|
|
{
|
|
|
|
$this->assertEqual($expected, $actual, $message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias to skipIf in SimpleTest
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function markTestSkipped($message = '')
|
|
|
|
{
|
|
|
|
$this->skipUnless(FALSE, $message);
|
|
|
|
}
|
2015-07-30 16:40:30 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias for phpunit method
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param string $message
|
|
|
|
* @param int $code
|
|
|
|
*/
|
|
|
|
public function setExpectedException($name, $message='', $code=NULL)
|
|
|
|
{
|
|
|
|
$this->expectException($name);
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit test bootstrap - Using php simpletest
|
|
|
|
*/
|
|
|
|
define('QTEST_DIR', __DIR__);
|
|
|
|
define('QBASE_DIR', realpath(__DIR__ . '/../') . '/');
|
|
|
|
define('QDS', DIRECTORY_SEPARATOR);
|
|
|
|
|
|
|
|
// Include db classes
|
|
|
|
require_once(QBASE_DIR . 'autoload.php');
|
|
|
|
|
|
|
|
// Include db tests
|
|
|
|
// Load db classes based on capability
|
|
|
|
$test_path = QTEST_DIR.'/databases/';
|
|
|
|
|
|
|
|
// Require base testing classes
|
|
|
|
require_once(QTEST_DIR . '/core/core.php');
|
2015-07-30 16:40:30 -04:00
|
|
|
require_once(QTEST_DIR . '/core/connection_manager_test.php');
|
2014-06-09 17:02:14 -04:00
|
|
|
require_once(QTEST_DIR . '/core/db_test.php');
|
2015-07-30 16:40:30 -04:00
|
|
|
//require_once(QTEST_DIR . '/core/query_parser_test.php');
|
|
|
|
require_once(QTEST_DIR . '/core/base_query_builder_test.php');
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2014-06-30 11:01:44 -04:00
|
|
|
$drivers = PDO::getAvailableDrivers();
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2014-06-30 11:01:44 -04:00
|
|
|
if (function_exists('fbird_connect'))
|
|
|
|
{
|
|
|
|
$drivers[] = 'interbase';
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2014-06-30 11:01:44 -04:00
|
|
|
$driver_test_map = array(
|
2015-07-29 16:51:17 -04:00
|
|
|
//'Firebird' => in_array('interbase', $drivers),
|
|
|
|
'MySQL' => in_array('mysql', $drivers),
|
2014-06-30 11:01:44 -04:00
|
|
|
'SQLite' => in_array('sqlite', $drivers),
|
|
|
|
'PgSQL' => in_array('pgsql', $drivers),
|
2015-07-29 16:51:17 -04:00
|
|
|
//'PDOFirebird' => in_array('firebird', $drivers)
|
2014-06-30 11:01:44 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
// Determine which testcases to load
|
|
|
|
foreach($driver_test_map as $name => $do_load)
|
|
|
|
{
|
|
|
|
$path = $test_path . strtolower($name) . '/';
|
|
|
|
|
2015-07-29 16:51:17 -04:00
|
|
|
if ($do_load && (! IS_QUERCUS))
|
2014-06-30 11:01:44 -04:00
|
|
|
{
|
|
|
|
require_once("{$path}{$name}Test.php");
|
|
|
|
require_once("{$path}{$name}QBTest.php");
|
|
|
|
}
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
// End of index.php
|