2014-02-14 22:08:19 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
2014-02-18 15:18:01 -05:00
|
|
|
* @copyright Copyright (c) 2012 - 2014
|
2014-02-14 22:08:19 -05:00
|
|
|
* @link https://github.com/aviat4ion/Query
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
2016-09-07 13:06:28 -04:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit test bootstrap - Using phpunit
|
|
|
|
*/
|
|
|
|
define('QTEST_DIR', realpath(__DIR__));
|
|
|
|
define('QBASE_DIR', realpath(QTEST_DIR.'/../') . '/');
|
|
|
|
define('QDS', DIRECTORY_SEPARATOR);
|
|
|
|
|
|
|
|
// Set up autoloader
|
2018-01-19 13:43:19 -05:00
|
|
|
require_once QBASE_DIR . 'vendor/autoload.php';
|
2016-09-07 13:06:28 -04:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2015-11-10 16:29:17 -05:00
|
|
|
function get_json_config()
|
|
|
|
{
|
|
|
|
$files = array(
|
|
|
|
__DIR__ . '/settings.json',
|
|
|
|
__DIR__ . '/settings.json.dist'
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach($files as $file)
|
|
|
|
{
|
|
|
|
if (is_file($file))
|
|
|
|
{
|
|
|
|
return json_decode(file_get_contents($file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
/**
|
|
|
|
* Base class for TestCases
|
|
|
|
*/
|
2016-09-07 13:06:28 -04:00
|
|
|
class Query_TestCase extends TestCase {
|
2014-02-21 15:02:41 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
/**
|
|
|
|
* Wrapper for Simpletest's assertEqual
|
2014-02-21 15:02:41 -05:00
|
|
|
*
|
2014-02-14 22:08:19 -05:00
|
|
|
* @param mixed $expected
|
|
|
|
* @param mixed $actual
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertEqual($expected, $actual, $message='')
|
|
|
|
{
|
|
|
|
$this->assertEquals($expected, $actual, $message);
|
|
|
|
}
|
2014-02-21 15:02:41 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
/**
|
|
|
|
* Wrapper for SimpleTest's assertIsA
|
|
|
|
*
|
|
|
|
* @param object $object
|
|
|
|
* @param string $type
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertIsA($object, $type, $message='')
|
|
|
|
{
|
|
|
|
$this->assertTrue(is_a($object, $type), $message);
|
|
|
|
}
|
2014-02-21 15:02:41 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
/**
|
|
|
|
* Implementation of SimpleTest's assertReference
|
2014-02-21 15:02:41 -05:00
|
|
|
*
|
2014-02-14 22:08:19 -05:00
|
|
|
* @param mixed $first
|
|
|
|
* @param mixed $second
|
|
|
|
* @param string $message
|
|
|
|
*/
|
|
|
|
public function assertReference($first, $second, $message='')
|
|
|
|
{
|
2014-02-21 15:02:41 -05:00
|
|
|
if (is_object($first))
|
2014-02-14 22:08:19 -05:00
|
|
|
{
|
2015-11-10 16:29:17 -05:00
|
|
|
$res = ($first === $second);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-14 22:08:19 -05:00
|
|
|
$temp = $first;
|
2015-11-10 16:29:17 -05:00
|
|
|
$first = uniqid("test");
|
2016-10-13 21:55:23 -04:00
|
|
|
$isRef = ($first === $second);
|
2015-11-10 16:29:17 -05:00
|
|
|
$first = $temp;
|
2016-10-13 21:55:23 -04:00
|
|
|
$res = $isRef;
|
2015-11-10 16:29:17 -05:00
|
|
|
}
|
|
|
|
$this->assertTrue($res, $message);
|
2014-02-14 22:08:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
2015-07-30 16:40:30 -04:00
|
|
|
$path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db';
|
|
|
|
@unlink($path);
|
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
// Require base testing classes
|
2015-07-31 10:24:34 -04:00
|
|
|
require_once(QTEST_DIR . '/core/base_db_test.php');
|
2015-07-30 16:40:30 -04:00
|
|
|
require_once(QTEST_DIR . '/core/base_query_builder_test.php');
|
2014-02-14 22:08:19 -05:00
|
|
|
|
2015-11-10 16:29:17 -05:00
|
|
|
|
2018-01-19 13:43:19 -05:00
|
|
|
// End of bootstrap.php
|