2018-01-19 16:48:52 -05:00
|
|
|
<?php declare(strict_types=1);
|
2014-06-09 17:02:14 -04:00
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
2018-01-19 16:50:34 -05:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2014-06-09 17:02:14 -04:00
|
|
|
*
|
2018-01-19 16:50:34 -05:00
|
|
|
* PHP version 7.1
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2012 - 2018 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @link https://git.timshomepage.net/aviat4ion/Query
|
2014-06-09 17:02:14 -04:00
|
|
|
*/
|
2018-01-19 16:48:52 -05:00
|
|
|
namespace {
|
|
|
|
/**
|
|
|
|
* Unit test bootstrap - Using php simpletest
|
|
|
|
*/
|
|
|
|
\define('QTEST_DIR', __DIR__);
|
|
|
|
\define('QBASE_DIR', realpath(__DIR__ . '/../') . '/');
|
|
|
|
\define('QDS', DIRECTORY_SEPARATOR);
|
|
|
|
|
|
|
|
require_once QBASE_DIR . 'vendor/simpletest/simpletest/autorun.php';
|
|
|
|
require_once QBASE_DIR . 'vendor/autoload.php';
|
|
|
|
}
|
2016-10-12 20:32:23 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
namespace Query\Tests {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for TestCases
|
|
|
|
*/
|
|
|
|
abstract class TestCase extends \UnitTestCase
|
2016-10-12 20:32:23 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
|
|
|
|
public function __construct()
|
2016-10-12 20:32:23 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
$class = \get_class($this);
|
2016-10-12 20:32:23 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
echo 'Ran test suite: ' . $class . '<br />';
|
2016-10-12 20:32:23 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
if (method_exists($class, 'setupBeforeClass')) {
|
|
|
|
$class::setupBeforeClass();
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
parent::__construct();
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
$class = \get_class($this);
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
if (method_exists($class, 'tearDownAfterClass')) {
|
|
|
|
$class::tearDownAfterClass();
|
|
|
|
}
|
|
|
|
}
|
2015-07-29 16:51:17 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
|
|
|
* Define assertInstanceOf for simpletest
|
|
|
|
*
|
|
|
|
* @param $expected
|
|
|
|
* @param $actual
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertInstanceOf($expected, $actual, $message = '')
|
2015-07-29 16:51:17 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
$this->assertIsA($actual, $expected, $message);
|
2015-07-29 16:51:17 -04:00
|
|
|
}
|
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
|
|
|
* Alias to assertEqual
|
|
|
|
*
|
|
|
|
* @param mixed $expected
|
|
|
|
* @param mixed $actual
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertEquals($expected, $actual, $message = '')
|
2015-07-30 16:40:30 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
$this->assertEqual($expected, $actual, $message);
|
2015-07-30 16:40:30 -04:00
|
|
|
}
|
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
|
|
|
* Alias to skipIf in SimpleTest
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function markTestSkipped($message = '')
|
|
|
|
{
|
|
|
|
$this->skipUnless(FALSE, $message);
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
|
|
|
* Alias to the method in PHPUnit
|
|
|
|
*
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function expectExceptionMessage($message)
|
|
|
|
{
|
|
|
|
// noop
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
}
|
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
}
|
2015-07-30 16:40:30 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
|
|
|
* Load the test suites
|
|
|
|
*/
|
|
|
|
namespace {
|
|
|
|
function get_json_config()
|
2016-10-12 20:32:23 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
$files = array(
|
|
|
|
__DIR__ . '/settings.json',
|
|
|
|
__DIR__ . '/settings.json.dist'
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if (is_file($file)) {
|
|
|
|
return json_decode(file_get_contents($file));
|
|
|
|
}
|
|
|
|
}
|
2016-10-12 20:32:23 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
return FALSE;
|
2015-07-30 16:40:30 -04:00
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
// Include db tests
|
|
|
|
// Load db classes based on capability
|
|
|
|
$testPath = QTEST_DIR.'/Drivers/';
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
// Require base testing classes
|
|
|
|
require_once QTEST_DIR . '/CoreTest.php';
|
|
|
|
require_once QTEST_DIR . '/ConnectionManagerTest.php';
|
|
|
|
require_once QTEST_DIR . '/QueryParserTest.php';
|
2014-06-30 11:01:44 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
$drivers = PDO::getAvailableDrivers();
|
2014-06-30 11:01:44 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
/* if (function_exists('fbird_connect'))
|
|
|
|
{
|
|
|
|
$drivers[] = 'interbase';
|
|
|
|
} */
|
|
|
|
|
|
|
|
$driverTestMap = [
|
|
|
|
'MySQL' => \in_array('mysql', $drivers, TRUE),
|
|
|
|
'SQLite' => \in_array('sqlite', $drivers, TRUE),
|
|
|
|
'PgSQL' => \in_array('pgsql', $drivers, TRUE),
|
|
|
|
// 'Firebird' => in_array('interbase', $drivers),
|
|
|
|
//'PDOFirebird' => in_array('firebird', $drivers)
|
|
|
|
];
|
|
|
|
|
|
|
|
// Determine which testcases to load
|
|
|
|
foreach($driverTestMap as $name => $doLoad)
|
2014-06-30 11:01:44 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
$path = $testPath . $name;
|
|
|
|
|
|
|
|
if ($doLoad)
|
|
|
|
{
|
|
|
|
require_once "{$path}/{$name}DriverTest.php";
|
|
|
|
require_once "{$path}/{$name}QueryBuilderTest.php";
|
|
|
|
}
|
2014-06-30 11:01:44 -04:00
|
|
|
}
|
|
|
|
}
|
2018-01-19 16:48:52 -05:00
|
|
|
|
|
|
|
|
2018-01-19 13:43:19 -05:00
|
|
|
// End of index.php
|