Update namespace of unsupported Firebird driver, add assertions to some risky tests
This commit is contained in:
parent
1eb146bb67
commit
89150ceafc
@ -3,26 +3,26 @@
|
|||||||
addUncoveredFilesFromWhitelist="true"
|
addUncoveredFilesFromWhitelist="true"
|
||||||
colors="true"
|
colors="true"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
bootstrap="../tests/bootstrap.php">
|
bootstrap="./../tests/bootstrap.php">
|
||||||
<filter>
|
<filter>
|
||||||
<whitelist>
|
<whitelist>
|
||||||
<directory suffix=".php">../src/*</directory>
|
<directory suffix=".php">./../src/*</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CoreTests">
|
<testsuite name="CoreTests">
|
||||||
<file>../tests/CoreTest.php</file>
|
<file>./../tests/CoreTest.php</file>
|
||||||
<file>../tests/ConnectionManagerTest.php</file>
|
<file>./../tests/ConnectionManagerTest.php</file>
|
||||||
<file>../tests/QueryParserTest.php</file>
|
<file>./../tests/QueryParserTest.php</file>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="MySQL Tests">
|
<testsuite name="MySQL Tests">
|
||||||
<directory>../tests/Drivers/MySQL/</directory>
|
<directory>./../tests/Drivers/MySQL/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="PgSQL Tests">
|
<testsuite name="PgSQL Tests">
|
||||||
<directory>../tests/Drivers/PgSQL/</directory>
|
<directory>./../tests/Drivers/PgSQL/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="SQLite Tests">
|
<testsuite name="SQLite Tests">
|
||||||
<directory>../tests/Drivers/SQLite/</directory>
|
<directory>./../tests/Drivers/SQLite/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<!-- <testsuite name="FirebirdTests">
|
<!-- <testsuite name="FirebirdTests">
|
||||||
<file>../tests/databases/firebird/FirebirdTest.php</file>
|
<file>../tests/databases/firebird/FirebirdTest.php</file>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
</testsuite> -->
|
</testsuite> -->
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<logging>
|
<logging>
|
||||||
<log type="coverage-html" target="coverage"/>
|
<log type="coverage-html" target="./../coverage"/>
|
||||||
<log type="coverage-clover" target="logs/clover.xml"/>
|
<log type="coverage-clover" target="logs/clover.xml"/>
|
||||||
<log type="coverage-xml" target="logs/coverage" />
|
<log type="coverage-xml" target="logs/coverage" />
|
||||||
<log type="xml" target="logs/junit.xml" logIncompleteSkipped="true"/>
|
<log type="xml" target="logs/junit.xml" logIncompleteSkipped="true"/>
|
||||||
|
@ -198,7 +198,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
|
|
||||||
foreach($arg as $k => $v)
|
foreach($arg as $k => $v)
|
||||||
{
|
{
|
||||||
if (in_array($valType, [self::KEY, self::VALUE]))
|
if (\in_array($valType, [self::KEY, self::VALUE], TRUE))
|
||||||
{
|
{
|
||||||
$var[] = ($valType === self::KEY)
|
$var[] = ($valType === self::KEY)
|
||||||
? $k
|
? $k
|
||||||
@ -225,7 +225,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
// Escape the identifiers
|
// Escape the identifiers
|
||||||
$field = $this->db->quoteIdent($field);
|
$field = $this->db->quoteIdent($field);
|
||||||
|
|
||||||
if ( ! is_string($as))
|
if ( ! \is_string($as))
|
||||||
{
|
{
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
@ -263,20 +263,20 @@ abstract class AbstractQueryBuilder {
|
|||||||
* @param string $pos
|
* @param string $pos
|
||||||
* @param string $like
|
* @param string $like
|
||||||
* @param string $conj
|
* @param string $conj
|
||||||
* @return QueryBuilderInterface
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function _like(string $field, $val, string $pos, string $like='LIKE', string $conj='AND'): QueryBuilderInterface
|
protected function _like(string $field, $val, string $pos, string $like='LIKE', string $conj='AND'): self
|
||||||
{
|
{
|
||||||
$field = $this->db->quoteIdent($field);
|
$field = $this->db->quoteIdent($field);
|
||||||
|
|
||||||
// Add the like string into the order map
|
// Add the like string into the order map
|
||||||
$like = $field. " {$like} ?";
|
$like = $field. " {$like} ?";
|
||||||
|
|
||||||
if ($pos == 'before')
|
if ($pos === 'before')
|
||||||
{
|
{
|
||||||
$val = "%{$val}";
|
$val = "%{$val}";
|
||||||
}
|
}
|
||||||
elseif ($pos == 'after')
|
elseif ($pos === 'after')
|
||||||
{
|
{
|
||||||
$val = "{$val}%";
|
$val = "{$val}%";
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
$val = "%{$val}%";
|
$val = "%{$val}%";
|
||||||
}
|
}
|
||||||
|
|
||||||
$conj = (empty($this->queryMap)) ? ' WHERE ' : " {$conj} ";
|
$conj = empty($this->queryMap) ? ' WHERE ' : " {$conj} ";
|
||||||
$this->_appendMap($conj, $like, 'like');
|
$this->_appendMap($conj, $like, 'like');
|
||||||
|
|
||||||
// Add to the values array
|
// Add to the values array
|
||||||
@ -298,13 +298,13 @@ abstract class AbstractQueryBuilder {
|
|||||||
* Simplify building having clauses
|
* Simplify building having clauses
|
||||||
*
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @param mixed $val
|
* @param mixed $values
|
||||||
* @param string $conj
|
* @param string $conj
|
||||||
* @return QueryBuilderInterface
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function _having($key, $val=[], string $conj='AND'): QueryBuilderInterface
|
protected function _having($key, $values=[], string $conj='AND'): self
|
||||||
{
|
{
|
||||||
$where = $this->_where($key, $val);
|
$where = $this->_where($key, $values);
|
||||||
|
|
||||||
// Create key/value placeholders
|
// Create key/value placeholders
|
||||||
foreach($where as $f => $val)
|
foreach($where as $f => $val)
|
||||||
@ -335,10 +335,10 @@ abstract class AbstractQueryBuilder {
|
|||||||
* @param mixed $val
|
* @param mixed $val
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _where($key, $val=[]): array
|
protected function _where($key, array $val=[]): array
|
||||||
{
|
{
|
||||||
$where = [];
|
$where = [];
|
||||||
$this->_mixedSet($where, $key, $val, self::BOTH);
|
$this->_mixedSet($where, $key, $val);
|
||||||
$this->_mixedSet($this->whereValues, $key, $val, self::VALUE);
|
$this->_mixedSet($this->whereValues, $key, $val, self::VALUE);
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
@ -347,14 +347,14 @@ abstract class AbstractQueryBuilder {
|
|||||||
* Simplify generating where string
|
* Simplify generating where string
|
||||||
*
|
*
|
||||||
* @param mixed $key
|
* @param mixed $key
|
||||||
* @param mixed $val
|
* @param mixed $values
|
||||||
* @param string $defaultConj
|
* @param string $defaultConj
|
||||||
* @return QueryBuilderInterface
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function _whereString($key, $val=[], string $defaultConj='AND'): QueryBuilderInterface
|
protected function _whereString($key, array $values=[], string $defaultConj='AND'): self
|
||||||
{
|
{
|
||||||
// Create key/value placeholders
|
// Create key/value placeholders
|
||||||
foreach($this->_where($key, $val) as $f => $val)
|
foreach($this->_where($key, $values) as $f => $val)
|
||||||
{
|
{
|
||||||
// Split each key by spaces, in case there
|
// Split each key by spaces, in case there
|
||||||
// is an operator such as >, <, !=, etc.
|
// is an operator such as >, <, !=, etc.
|
||||||
@ -394,9 +394,9 @@ abstract class AbstractQueryBuilder {
|
|||||||
* @param mixed $val
|
* @param mixed $val
|
||||||
* @param string $in - The (not) in fragment
|
* @param string $in - The (not) in fragment
|
||||||
* @param string $conj - The where in conjunction
|
* @param string $conj - The where in conjunction
|
||||||
* @return QueryBuilderInterface
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function _whereIn($key, $val=[], string $in='IN', string $conj='AND'): QueryBuilderInterface
|
protected function _whereIn($key, $val=[], string $in='IN', string $conj='AND'): self
|
||||||
{
|
{
|
||||||
$key = $this->db->quoteIdent($key);
|
$key = $this->db->quoteIdent($key);
|
||||||
$params = array_fill(0, count($val), '?');
|
$params = array_fill(0, count($val), '?');
|
||||||
@ -426,19 +426,19 @@ abstract class AbstractQueryBuilder {
|
|||||||
*/
|
*/
|
||||||
protected function _run(string $type, string $table, $sql=NULL, $vals=NULL, bool $reset=TRUE): PDOStatement
|
protected function _run(string $type, string $table, $sql=NULL, $vals=NULL, bool $reset=TRUE): PDOStatement
|
||||||
{
|
{
|
||||||
if (is_null($sql))
|
if ($sql === NULL)
|
||||||
{
|
{
|
||||||
$sql = $this->_compile($type, $table);
|
$sql = $this->_compile($type, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($vals))
|
if ($vals === NULL)
|
||||||
{
|
{
|
||||||
$vals = array_merge($this->values, (array) $this->whereValues);
|
$vals = array_merge($this->values, (array) $this->whereValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startTime = microtime(TRUE);
|
$startTime = microtime(TRUE);
|
||||||
|
|
||||||
$res = (empty($vals))
|
$res = empty($vals)
|
||||||
? $this->db->query($sql)
|
? $this->db->query($sql)
|
||||||
: $this->db->prepareExecute($sql, $vals);
|
: $this->db->prepareExecute($sql, $vals);
|
||||||
|
|
||||||
@ -467,11 +467,11 @@ abstract class AbstractQueryBuilder {
|
|||||||
*/
|
*/
|
||||||
protected function _appendMap(string $conjunction = '', string $string = '', string $type = '')
|
protected function _appendMap(string $conjunction = '', string $string = '', string $type = '')
|
||||||
{
|
{
|
||||||
array_push($this->queryMap, [
|
$this->queryMap[] = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'conjunction' => $conjunction,
|
'conjunction' => $conjunction,
|
||||||
'string' => $string
|
'string' => $string
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -500,7 +500,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
// Add the interpreted query to the list of executed queries
|
// Add the interpreted query to the list of executed queries
|
||||||
$this->queries[] = [
|
$this->queries[] = [
|
||||||
'time' => $totalTime,
|
'time' => $totalTime,
|
||||||
'sql' => call_user_func_array('sprintf', $evals),
|
'sql' => sprintf(...$evals)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->queries['total_time'] += $totalTime;
|
$this->queries['total_time'] += $totalTime;
|
||||||
@ -520,7 +520,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
{
|
{
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case "insert":
|
case 'insert':
|
||||||
$paramCount = count($this->setArrayKeys);
|
$paramCount = count($this->setArrayKeys);
|
||||||
$params = array_fill(0, $paramCount, '?');
|
$params = array_fill(0, $paramCount, '?');
|
||||||
$sql = "INSERT INTO {$table} ("
|
$sql = "INSERT INTO {$table} ("
|
||||||
@ -528,16 +528,16 @@ abstract class AbstractQueryBuilder {
|
|||||||
. ")\nVALUES (".implode(',', $params).')';
|
. ")\nVALUES (".implode(',', $params).')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "update":
|
case 'update':
|
||||||
$sql = "UPDATE {$table}\nSET {$this->setString}";
|
$sql = "UPDATE {$table}\nSET {$this->setString}";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "replace":
|
case 'replace':
|
||||||
// @TODO implement
|
// @TODO implement
|
||||||
$sql = "";
|
$sql = '';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "delete":
|
case 'delete':
|
||||||
$sql = "DELETE FROM {$table}";
|
$sql = "DELETE FROM {$table}";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ abstract class AbstractQueryBuilder {
|
|||||||
foreach($clauses as $clause)
|
foreach($clauses as $clause)
|
||||||
{
|
{
|
||||||
$param = $this->$clause;
|
$param = $this->$clause;
|
||||||
if (is_array($param))
|
if (\is_array($param))
|
||||||
{
|
{
|
||||||
foreach($param as $q)
|
foreach($param as $q)
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,6 @@ use Query\{
|
|||||||
QueryBuilderInterface
|
QueryBuilderInterface
|
||||||
};
|
};
|
||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ class CoreTest extends TestCase {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testPHPVersion()
|
public function testPHPVersion(): void
|
||||||
{
|
{
|
||||||
//$this->assertTrue(version_compare(PHP_VERSION, '7.1', 'ge'));
|
//$this->assertTrue(version_compare(PHP_VERSION, '7.1', 'ge'));
|
||||||
$this->assertTrue(PHP_VERSION_ID >= 70000);
|
$this->assertTrue(PHP_VERSION_ID >= 70000);
|
||||||
@ -44,7 +44,7 @@ class CoreTest extends TestCase {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testHasPDO()
|
public function testHasPDO(): void
|
||||||
{
|
{
|
||||||
// PDO class exists
|
// PDO class exists
|
||||||
$this->assertTrue(class_exists('PDO'));
|
$this->assertTrue(class_exists('PDO'));
|
||||||
@ -52,10 +52,8 @@ class CoreTest extends TestCase {
|
|||||||
|
|
||||||
// Make sure at least one of the supported drivers is enabled
|
// Make sure at least one of the supported drivers is enabled
|
||||||
$supported = [
|
$supported = [
|
||||||
'firebird',
|
|
||||||
'mysql',
|
'mysql',
|
||||||
'pgsql',
|
'pgsql',
|
||||||
'odbc',
|
|
||||||
'sqlite',
|
'sqlite',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
* @link https://git.timshomepage.net/aviat4ion/Query
|
* @link https://git.timshomepage.net/aviat4ion/Query
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Query\Tests\Drivers;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Query\Drivers\Firebird\Driver;
|
||||||
|
use Query\Tests\BaseDriverTest;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -24,20 +29,20 @@
|
|||||||
* @extends DBtest
|
* @extends DBtest
|
||||||
* @requires extension interbase
|
* @requires extension interbase
|
||||||
*/
|
*/
|
||||||
class FirebirdTest extends DBtest {
|
class FirebirdDriverTest extends BaseDriverTest {
|
||||||
|
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass()
|
||||||
{
|
{
|
||||||
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
||||||
|
|
||||||
// test the db driver directly
|
// test the db driver directly
|
||||||
self::$db = new \Query\Drivers\Firebird\Driver('localhost:'.$dbpath);
|
self::$db = new Driver('localhost:'.$dbpath);
|
||||||
self::$db->setTablePrefix('create_');
|
self::$db->setTablePrefix('create_');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
if ( ! function_exists('\\fbird_connect'))
|
if ( ! \function_exists('\\fbird_connect'))
|
||||||
{
|
{
|
||||||
$this->markTestSkipped('Firebird extension does not exist');
|
$this->markTestSkipped('Firebird extension does not exist');
|
||||||
}
|
}
|
||||||
@ -73,15 +78,15 @@ class FirebirdTest extends DBtest {
|
|||||||
|
|
||||||
public function testExists()
|
public function testExists()
|
||||||
{
|
{
|
||||||
$this->assertTrue(function_exists('ibase_connect'));
|
$this->assertTrue(\function_exists('ibase_connect'));
|
||||||
$this->assertTrue(function_exists('fbird_connect'));
|
$this->assertTrue(\function_exists('fbird_connect'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
public function testConnection()
|
public function testConnection()
|
||||||
{
|
{
|
||||||
$this->assertIsA(self::$db, '\\Query\\Drivers\\Firebird\\Driver');
|
$this->assertIsA(self::$db, Driver::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -119,7 +124,7 @@ class FirebirdTest extends DBtest {
|
|||||||
self::$db->query($sql);
|
self::$db->query($sql);
|
||||||
|
|
||||||
//Check
|
//Check
|
||||||
$this->assertTrue(in_array('create_delete', self::$db->getTables()));
|
$this->assertTrue(\in_array('create_delete', self::$db->getTables(), TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -131,7 +136,7 @@ class FirebirdTest extends DBtest {
|
|||||||
self::$db->query($sql);
|
self::$db->query($sql);
|
||||||
|
|
||||||
//Check
|
//Check
|
||||||
$tableExists = in_array('create_delete', self::$db->getTables());
|
$tableExists = \in_array('create_delete', self::$db->getTables(), TRUE);
|
||||||
$this->assertFalse($tableExists);
|
$this->assertFalse($tableExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +219,7 @@ SQL;
|
|||||||
// Numeric array
|
// Numeric array
|
||||||
$res2 = self::$db->query('SELECT "id","key","val" FROM "create_test"');
|
$res2 = self::$db->query('SELECT "id","key","val" FROM "create_test"');
|
||||||
$fetch = $res2->fetch(PDO::FETCH_NUM);
|
$fetch = $res2->fetch(PDO::FETCH_NUM);
|
||||||
$this->assertTrue(is_array($fetch));
|
$this->assertTrue(\is_array($fetch));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
@ -13,6 +13,11 @@
|
|||||||
* @link https://git.timshomepage.net/aviat4ion/Query
|
* @link https://git.timshomepage.net/aviat4ion/Query
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Query\Tests\Drivers;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Query\Tests\BaseQueryBuilderTest;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -20,14 +25,14 @@
|
|||||||
* Firebird Query Builder Tests
|
* Firebird Query Builder Tests
|
||||||
* @requires extension interbase
|
* @requires extension interbase
|
||||||
*/
|
*/
|
||||||
class FirebirdQBTest extends QBTest {
|
class FirebirdQueryBuilderTest extends BaseQueryBuilderTest {
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
||||||
|
|
||||||
// test the query builder
|
// test the query builder
|
||||||
$params = new Stdclass();
|
$params = new \Stdclass();
|
||||||
$params->alias = 'fire';
|
$params->alias = 'fire';
|
||||||
$params->type = 'firebird';
|
$params->type = 'firebird';
|
||||||
$params->file = $dbpath;
|
$params->file = $dbpath;
|
||||||
@ -40,7 +45,7 @@ class FirebirdQBTest extends QBTest {
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
if ( ! function_exists('\\fbird_connect'))
|
if ( ! \function_exists('\\fbird_connect'))
|
||||||
{
|
{
|
||||||
$this->markTestSkipped('Firebird extension does not exist');
|
$this->markTestSkipped('Firebird extension does not exist');
|
||||||
}
|
}
|
||||||
@ -76,7 +81,7 @@ class FirebirdQBTest extends QBTest {
|
|||||||
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
$dbpath = QTEST_DIR.QDS.'db_files'.QDS.'FB_TEST_DB.FDB';
|
||||||
|
|
||||||
// test the query builder
|
// test the query builder
|
||||||
$params = new Stdclass();
|
$params = new \Stdclass();
|
||||||
$params->alias = 'wood';
|
$params->alias = 'wood';
|
||||||
$params->type = 'firebird';
|
$params->type = 'firebird';
|
||||||
$params->file = $dbpath;
|
$params->file = $dbpath;
|
@ -17,6 +17,7 @@ namespace Query\Tests\Drivers\PgSQL;
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use PDO;
|
||||||
use Query\Drivers\Pgsql\Driver;
|
use Query\Drivers\Pgsql\Driver;
|
||||||
use Query\Tests\BaseDriverTest;
|
use Query\Tests\BaseDriverTest;
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class PgSQLDriverTest extends BaseDriverTest {
|
|||||||
|
|
||||||
public function testExists()
|
public function testExists()
|
||||||
{
|
{
|
||||||
$drivers = \PDO::getAvailableDrivers();
|
$drivers = PDO::getAvailableDrivers();
|
||||||
$this->assertTrue(in_array('pgsql', $drivers, TRUE));
|
$this->assertTrue(in_array('pgsql', $drivers, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +148,14 @@ SQL;
|
|||||||
|
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
|
$res = self::$db->query('SELECT * FROM "create_test" WHERE "id"=1')
|
||||||
|
->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'id' => 1,
|
||||||
|
'key' => 'boogers',
|
||||||
|
'val' => 'Gross'
|
||||||
|
], $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -174,9 +183,17 @@ SQL;
|
|||||||
VALUES (?,?,?)
|
VALUES (?,?,?)
|
||||||
SQL;
|
SQL;
|
||||||
self::$db->prepareExecute($sql, array(
|
self::$db->prepareExecute($sql, array(
|
||||||
2, "works", 'also?'
|
2, 'works', 'also?'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$res = self::$db->query('SELECT * FROM "create_test" WHERE "id"=2')
|
||||||
|
->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'id' => 2,
|
||||||
|
'key' => 'works',
|
||||||
|
'val' => 'also?'
|
||||||
|
], $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -30,7 +30,6 @@ class SQLiteDriverTest extends BaseDriverTest {
|
|||||||
|
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass()
|
||||||
{
|
{
|
||||||
$path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db';
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'type' => 'sqlite',
|
'type' => 'sqlite',
|
||||||
'file' => ':memory:',
|
'file' => ':memory:',
|
||||||
@ -56,13 +55,13 @@ class SQLiteDriverTest extends BaseDriverTest {
|
|||||||
//Check
|
//Check
|
||||||
$dbs = self::$db->getTables();
|
$dbs = self::$db->getTables();
|
||||||
|
|
||||||
$this->assertTrue(in_array('TEST1', $dbs, TRUE));
|
$this->assertTrue(\in_array('TEST1', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('TEST2', $dbs, TRUE));
|
$this->assertTrue(\in_array('TEST2', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('NUMBERS', $dbs, TRUE));
|
$this->assertTrue(\in_array('NUMBERS', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('NEWTABLE', $dbs, TRUE));
|
$this->assertTrue(\in_array('NEWTABLE', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('create_test', $dbs, TRUE));
|
$this->assertTrue(\in_array('create_test', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('create_join', $dbs, TRUE));
|
$this->assertTrue(\in_array('create_join', $dbs, TRUE));
|
||||||
$this->assertTrue(in_array('create_delete', $dbs, TRUE));
|
$this->assertTrue(\in_array('create_delete', $dbs, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -209,6 +208,14 @@ SQL;
|
|||||||
|
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
|
$res = self::$db->query('SELECT * FROM "create_test" WHERE "id"=1')
|
||||||
|
->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'id' => 1,
|
||||||
|
'key' => 'boogers',
|
||||||
|
'val' => 'Gross'
|
||||||
|
], $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -223,6 +230,14 @@ SQL;
|
|||||||
2, "works", 'also?'
|
2, "works", 'also?'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$res = self::$db->query('SELECT * FROM "create_test" WHERE "id"=2')
|
||||||
|
->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'id' => 2,
|
||||||
|
'key' => 'works',
|
||||||
|
'val' => 'also?'
|
||||||
|
], $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -131,18 +131,10 @@ namespace {
|
|||||||
require_once QTEST_DIR . '/QueryParserTest.php';
|
require_once QTEST_DIR . '/QueryParserTest.php';
|
||||||
|
|
||||||
$drivers = PDO::getAvailableDrivers();
|
$drivers = PDO::getAvailableDrivers();
|
||||||
|
|
||||||
/* if (function_exists('fbird_connect'))
|
|
||||||
{
|
|
||||||
$drivers[] = 'interbase';
|
|
||||||
} */
|
|
||||||
|
|
||||||
$driverTestMap = [
|
$driverTestMap = [
|
||||||
'MySQL' => \in_array('mysql', $drivers, TRUE),
|
'MySQL' => \in_array('mysql', $drivers, TRUE),
|
||||||
'SQLite' => \in_array('sqlite', $drivers, TRUE),
|
'SQLite' => \in_array('sqlite', $drivers, TRUE),
|
||||||
'PgSQL' => \in_array('pgsql', $drivers, TRUE),
|
'PgSQL' => \in_array('pgsql', $drivers, TRUE),
|
||||||
// 'Firebird' => in_array('interbase', $drivers),
|
|
||||||
//'PDOFirebird' => in_array('firebird', $drivers)
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Determine which testcases to load
|
// Determine which testcases to load
|
||||||
|
Loading…
Reference in New Issue
Block a user