2015-07-20 15:24:21 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
|
|
|
* @copyright Copyright (c) 2012 - 2014
|
|
|
|
* @link https://github.com/aviat4ion/Query
|
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Firebird Query Builder Tests
|
|
|
|
* @requires extension interbase
|
|
|
|
*/
|
|
|
|
class PDOFirebirdQBTest extends QBTest {
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
if ( ! in_array('firebird', PDO::getAvailableDrivers()))
|
|
|
|
{
|
|
|
|
$this->markTestSkipped('PDO Firebird extension does not exist');
|
|
|
|
}
|
|
|
|
|
|
|
|
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
|
|
|
|
|
|
|
// test the query builder
|
|
|
|
$params = new Stdclass();
|
|
|
|
$params->alias = 'fire';
|
|
|
|
$params->type = 'pdo_firebird';
|
|
|
|
$params->database = $dbpath;
|
|
|
|
$params->host = 'localhost';
|
|
|
|
$params->user = 'SYSDBA';
|
|
|
|
$params->pass = 'masterkey';
|
|
|
|
$params->prefix = 'create_';
|
|
|
|
|
2015-07-30 16:40:30 -04:00
|
|
|
self::$db = Query($params);
|
2015-07-20 15:24:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testQueryFunctionAlias()
|
|
|
|
{
|
2015-07-31 10:24:34 -04:00
|
|
|
$this->markTestSkipped();
|
|
|
|
if (version_compare(PHP_VERSION, '7.0.0', '<='))
|
|
|
|
{
|
|
|
|
$this->markTestSkipped("Segfaults on this version of PHP");
|
|
|
|
}
|
|
|
|
|
2015-07-20 15:24:21 -04:00
|
|
|
$db = Query();
|
|
|
|
|
2015-07-30 16:40:30 -04:00
|
|
|
$this->assertTrue(self::$db === $db);
|
2015-07-20 15:24:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNamedConnectionException()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$db = Query('water');
|
|
|
|
}
|
|
|
|
catch(InvalidArgumentException $e)
|
|
|
|
{
|
|
|
|
$this->assertIsA($e, 'InvalidArgumentException');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNamedConnection()
|
|
|
|
{
|
|
|
|
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
|
|
|
|
|
|
|
// test the query builder
|
|
|
|
$params = new Stdclass();
|
|
|
|
$params->alias = 'wood';
|
|
|
|
$params->type = 'pdo_firebird';
|
|
|
|
$params->database = $dbpath;
|
|
|
|
$params->host = 'localhost';
|
|
|
|
$params->user = 'sysdba';
|
|
|
|
$params->pass = 'masterkey';
|
|
|
|
$params->prefix = '';
|
|
|
|
$f_conn = Query($params);
|
|
|
|
$q_conn = Query('wood');
|
|
|
|
|
|
|
|
$this->assertReference($f_conn, $q_conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testTypeList()
|
|
|
|
{
|
2015-07-31 10:24:34 -04:00
|
|
|
$this->markTestIncomplete();
|
|
|
|
if (version_compare(PHP_VERSION, '7.0.0', '<='))
|
|
|
|
{
|
|
|
|
$this->markTestSkipped("Segfaults on this version of PHP");
|
|
|
|
}
|
|
|
|
|
2015-07-20 15:24:21 -04:00
|
|
|
$this->doSetUp();
|
2015-07-30 16:40:30 -04:00
|
|
|
$sql = self::$db->get_sql()->type_list();
|
|
|
|
$query = self::$db->query($sql);
|
2015-07-20 15:24:21 -04:00
|
|
|
|
|
|
|
$this->assertIsA('PDOStatement', $query);
|
|
|
|
|
|
|
|
$res = $query->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
$this->assertTrue(is_array($res));
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testQueryExplain()
|
|
|
|
{
|
2015-07-30 16:40:30 -04:00
|
|
|
$res = self::$db->select('id, key as k, val')
|
2015-07-20 15:24:21 -04:00
|
|
|
->explain()
|
|
|
|
->where('id >', 1)
|
|
|
|
->where('id <', 900)
|
|
|
|
->limit(2, 1)
|
|
|
|
->get_compiled_select();
|
|
|
|
|
2015-07-30 16:40:30 -04:00
|
|
|
$res2 = self::$db->select('id, key as k, val')
|
2015-07-20 15:24:21 -04:00
|
|
|
->where('id >', 1)
|
|
|
|
->where('id <', 900)
|
|
|
|
->limit(2, 1)
|
|
|
|
->get_compiled_select();
|
|
|
|
|
|
|
|
// Queries are equal because explain is not a keyword in Firebird
|
|
|
|
$this->assertEqual($res, $res2);
|
|
|
|
}
|
|
|
|
}
|