Remove method separators, update documentation building configuration

This commit is contained in:
Timothy Warren 2018-01-24 15:03:41 -05:00
parent 2a5b623edc
commit f967aaf96e
25 changed files with 108 additions and 393 deletions

View File

@ -40,7 +40,7 @@ class RoboFile extends \Robo\Tasks {
*/ */
protected $cleanDirs = [ protected $cleanDirs = [
'coverage', 'coverage',
'docs', 'apiDocumentation',
'phpdoc', 'phpdoc',
'build/logs', 'build/logs',
'build/phpdox', 'build/phpdox',
@ -76,14 +76,6 @@ class RoboFile extends \Robo\Tasks {
*/ */
public function clean() public function clean()
{ {
$cleanFiles = [
'build/humbug.json',
'build/humbug-log.txt',
];
array_map(function ($file) {
@unlink($file);
}, $cleanFiles);
// So the task doesn't complain, // So the task doesn't complain,
// make any 'missing' dirs to cleanup // make any 'missing' dirs to cleanup
array_map(function ($dir) { array_map(function ($dir) {
@ -102,10 +94,7 @@ class RoboFile extends \Robo\Tasks {
*/ */
public function coverage() public function coverage()
{ {
$this->taskPhpUnit() $this->_run(['phpdbg -qrr -- vendor/bin/phpunit -c build']);
->configFile('build/phpunit.xml')
->printed(true)
->run();
} }
/** /**
@ -113,10 +102,7 @@ class RoboFile extends \Robo\Tasks {
*/ */
public function docs() public function docs()
{ {
$cmd_parts = [ $this->_run(['vendor/bin/phpdox']);
'phpdoc'
];
$this->_run($cmd_parts, ' && ');
} }
/** /**
@ -134,29 +120,6 @@ class RoboFile extends \Robo\Tasks {
} }
} }
/**
* Run mutation tests with humbug
*
* @param bool $stats - if true, generates stats rather than running mutation tests
*/
public function mutate($stats = FALSE)
{
$test_parts = [
'vendor/bin/humbug'
];
$stat_parts = [
'vendor/bin/humbug',
'--skip-killed=yes',
'-v',
'./build/humbug.json'
];
$cmd_parts = ($stats) ? $stat_parts : $test_parts;
$this->_run($cmd_parts);
}
/** /**
* Run the phpcs tool * Run the phpcs tool
* *
@ -226,9 +189,8 @@ class RoboFile extends \Robo\Tasks {
public function test() public function test()
{ {
$this->lint(); $this->lint();
$this->taskPHPUnit() $this->taskPhpUnit()
->configFile('phpunit.xml') ->configFile('phpunit.xml')
->printed(true)
->run(); ->run();
$this->_run(["php tests/index.php"]); $this->_run(["php tests/index.php"]);
} }

View File

@ -21,20 +21,19 @@
"role": "Developer" "role": "Developer"
}], }],
"require": { "require": {
"php": "^7.0" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"consolidation/robo": "^1.0.0", "consolidation/robo": "^1.0.0",
"infection/infection": "^0.7.0",
"monolog/monolog": "^1.21", "monolog/monolog": "^1.21",
"pdepend/pdepend": "^2.5", "pdepend/pdepend": "^2.5",
"phploc/phploc": "^4.0", "phploc/phploc": "^4.0",
"phpmd/phpmd": "^2.4",
"phpstan/phpstan": "^0.9.1", "phpstan/phpstan": "^0.9.1",
"phpunit/phpunit": "^6.5", "phpunit/phpunit": "^6.5",
"sebastian/phpcpd": "^2.0", "sebastian/phpcpd": "^3.0",
"simpletest/simpletest": "^1.1", "simpletest/simpletest": "^1.1",
"squizlabs/php_codesniffer": "^3.0.0" "squizlabs/php_codesniffer": "^3.0.0",
"theseer/phpdox": "^0.11.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -48,6 +47,8 @@
} }
}, },
"scripts": { "scripts": {
"build": "robo build",
"clean": "robo clean",
"coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build", "coverage": "phpdbg -qrr -- vendor/bin/phpunit -c build",
"phpstan": "phpstan analyse -l 3 -c phpstan.neon src tests", "phpstan": "phpstan analyse -l 3 -c phpstan.neon src tests",
"test": "phpunit -c build --no-coverage" "test": "phpunit -c build --no-coverage"

View File

@ -9,7 +9,7 @@
<bootstrap /> <bootstrap />
<!-- A phpDox project to process, you can have multiple projects in one config file --> <!-- A phpDox project to process, you can have multiple projects in one config file -->
<project name="Query" source="../src" workdir="phpdox/xml"> <project name="Query" source="src" workdir="build/phpdox/xml">
<!-- @name - The name of the project --> <!-- @name - The name of the project -->
<!-- @source - The source directory of the application to process --> <!-- @source - The source directory of the application to process -->
<!-- @workdir - The directory to store the xml data files in --> <!-- @workdir - The directory to store the xml data files in -->
@ -56,12 +56,12 @@
</collector> </collector>
<!-- Configuration of generation process --> <!-- Configuration of generation process -->
<generator output="../docs"> <generator output="apiDocumentation">
<!-- @output - (Base-)Directory to store output data in --> <!-- @output - (Base-)Directory to store output data in -->
<!-- A generation process consists of one or more build tasks and of (optional) enrich sources --> <!-- A generation process consists of one or more build tasks and of (optional) enrich sources -->
<enrich base="logs"> <enrich base="build/logs">
<!-- @base - (Base-)Directory of datafiles used for enrich process --> <!-- @base - (Base-)Directory of datafiles used for enrich process -->
<!--<source type="...">--> <!--<source type="...">-->
@ -84,11 +84,9 @@
</source> </source>
<!-- PHP Code Sniffer findings --> <!-- PHP Code Sniffer findings -->
<!--
<source type="phpcs"> <source type="phpcs">
<file name="logs/phpcs.xml" /> <file name="phpcs.xml" />
</source> </source>
-->
<!-- PHPMessDetector --> <!-- PHPMessDetector -->
<!-- <!--
@ -99,7 +97,7 @@
<!-- PHPUnit Coverage XML --> <!-- PHPUnit Coverage XML -->
<source type="phpunit"> <source type="phpunit">
<coverage path="logs/coverage.xml" /> <coverage path="coverage" />
<!-- <coverage path="clover.xml" />--> <!-- <coverage path="clover.xml" />-->
<!-- @path - the directory where the xml code coverage report can be found --> <!-- @path - the directory where the xml code coverage report can be found -->
<!--<filter directory="${phpDox.project.source}" />--> <!--<filter directory="${phpDox.project.source}" />-->

View File

@ -18,9 +18,6 @@ use InvalidArgumentException;
/** /**
* Generic exception for bad drivers * Generic exception for bad drivers
*
* @package Query
* @subpackage Core
*/ */
class BadDBDriverException extends InvalidArgumentException { class BadDBDriverException extends InvalidArgumentException {
} }

View File

@ -544,7 +544,7 @@ abstract class AbstractDriver
$sql = "INSERT INTO {$table} (" $sql = "INSERT INTO {$table} ("
. implode(',', $this->quoteIdent($fields)) . implode(',', $this->quoteIdent($fields))
. ") VALUES "; . ') VALUES ';
// Create the placeholder groups // Create the placeholder groups
$params = array_fill(0, count($fields), '?'); $params = array_fill(0, count($fields), '?');

View File

@ -15,10 +15,7 @@
namespace Query\Drivers; namespace Query\Drivers;
/** /**
* parent for database manipulation subclasses * Parent for database-specific syntax subclasses
*
* @package Query
* @subpackage Drivers
*/ */
abstract class AbstractSQL implements SQLInterface { abstract class AbstractSQL implements SQLInterface {

View File

@ -40,8 +40,6 @@ class Driver extends AbstractDriver {
parent::__construct($dsn, $username, $password, $options); parent::__construct($dsn, $username, $password, $options);
} }
// --------------------------------------------------------------------------
/** /**
* Get a list of schemas for the current connection * Get a list of schemas for the current connection
* *
@ -58,8 +56,6 @@ SQL;
return $this->driverQuery($sql); return $this->driverQuery($sql);
} }
// --------------------------------------------------------------------------
/** /**
* Retrieve foreign keys for the table * Retrieve foreign keys for the table
* *

View File

@ -15,10 +15,7 @@
namespace Query\Drivers; namespace Query\Drivers;
/** /**
* parent for database manipulation subclasses * Interface for database-specific syntax subclasses
*
* @package Query
* @subpackage Drivers
*/ */
interface SQLInterface { interface SQLInterface {

View File

@ -121,12 +121,12 @@ class Driver extends AbstractDriver {
{ {
$cols[] = $this->_quote($datum) . ' AS ' . $this->quoteIdent($colname); $cols[] = $this->_quote($datum) . ' AS ' . $this->quoteIdent($colname);
} }
$sql .= "SELECT " . implode(', ', $cols) . "\n"; $sql .= 'SELECT ' . implode(', ', $cols) . "\n";
foreach($data as $union) foreach($data as $union)
{ {
$vals = array_map([$this, 'quote'], $union); $vals = array_map([$this, 'quote'], $union);
$sql .= "UNION SELECT " . implode(',', $vals) . "\n"; $sql .= 'UNION SELECT ' . implode(',', $vals) . "\n";
} }
return [$sql, NULL]; return [$sql, NULL];

View File

@ -20,8 +20,6 @@ use Query\Drivers\AbstractUtil;
/** /**
* SQLite-specific backup, import and creation methods * SQLite-specific backup, import and creation methods
* *
* @package Query
* @subpackage Drivers
* @method mixed query(string $sql) * @method mixed query(string $sql)
* @method string quote(string $str) * @method string quote(string $str)
*/ */

View File

@ -258,7 +258,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $tblname * @param string $tblname
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function from($tblname): QueryBuilderInterface public function from(string $tblname): QueryBuilderInterface
{ {
// Split identifiers on spaces // Split identifiers on spaces
$identArray = explode(' ', \mb_trim($tblname)); $identArray = explode(' ', \mb_trim($tblname));
@ -286,7 +286,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function like($field, $val, $pos='both'): QueryBuilderInterface public function like(string $field, $val, string $pos='both'): QueryBuilderInterface
{ {
return $this->_like($field, $val, $pos); return $this->_like($field, $val, $pos);
} }
@ -299,7 +299,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orLike($field, $val, $pos='both'): QueryBuilderInterface public function orLike(string $field, $val, string $pos='both'): QueryBuilderInterface
{ {
return $this->_like($field, $val, $pos, 'LIKE', 'OR'); return $this->_like($field, $val, $pos, 'LIKE', 'OR');
} }
@ -312,9 +312,9 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function notLike($field, $val, $pos='both'): QueryBuilderInterface public function notLike(string $field, $val, string $pos='both'): QueryBuilderInterface
{ {
return $this->_like($field, $val, $pos, 'NOT LIKE', 'AND'); return $this->_like($field, $val, $pos, 'NOT LIKE');
} }
/** /**
@ -325,7 +325,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orNotLike($field, $val, $pos='both'): QueryBuilderInterface public function orNotLike(string $field, $val, string $pos='both'): QueryBuilderInterface
{ {
return $this->_like($field, $val, $pos, 'NOT LIKE', 'OR'); return $this->_like($field, $val, $pos, 'NOT LIKE', 'OR');
} }
@ -343,7 +343,7 @@ class QueryBuilder implements QueryBuilderInterface {
*/ */
public function having($key, $val=[]): QueryBuilderInterface public function having($key, $val=[]): QueryBuilderInterface
{ {
return $this->_having($key, $val, 'AND'); return $this->_having($key, $val);
} }
/** /**
@ -422,7 +422,7 @@ class QueryBuilder implements QueryBuilderInterface {
*/ */
public function whereNotIn($field, $val=[]): QueryBuilderInterface public function whereNotIn($field, $val=[]): QueryBuilderInterface
{ {
return $this->_whereIn($field, $val, 'NOT IN', 'AND'); return $this->_whereIn($field, $val, 'NOT IN');
} }
/** /**
@ -488,7 +488,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $type * @param string $type
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function join($table, $condition, $type=''): QueryBuilderInterface public function join(string $table, string $condition, string $type=''): QueryBuilderInterface
{ {
// Prefix and quote table name // Prefix and quote table name
$table = explode(' ', mb_trim($table)); $table = explode(' ', mb_trim($table));
@ -537,7 +537,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $type * @param string $type
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orderBy($field, $type=''): QueryBuilderInterface public function orderBy(string $field, string $type=''): QueryBuilderInterface
{ {
// When ordering by random, do an ascending order if the driver // When ordering by random, do an ascending order if the driver
// doesn't support random ordering // doesn't support random ordering
@ -560,7 +560,7 @@ class QueryBuilder implements QueryBuilderInterface {
} }
// Set the final string // Set the final string
$orderString = ( ! isset($rand)) $orderString = ! isset($rand)
? "\nORDER BY ".implode(', ', $orderClauses) ? "\nORDER BY ".implode(', ', $orderClauses)
: "\nORDER BY".$rand; : "\nORDER BY".$rand;
@ -576,7 +576,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param int|bool $offset * @param int|bool $offset
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function limit($limit, $offset=FALSE): QueryBuilderInterface public function limit(int $limit, $offset=FALSE): QueryBuilderInterface
{ {
$this->state->setLimit($limit); $this->state->setLimit($limit);
$this->state->setOffset($offset); $this->state->setOffset($offset);
@ -668,7 +668,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param int|bool $offset * @param int|bool $offset
* @return PDOStatement * @return PDOStatement
*/ */
public function get($table='', $limit=FALSE, $offset=FALSE): PDOStatement public function get(string $table='', $limit=FALSE, $offset=FALSE): ?PDOStatement
{ {
// Set the table // Set the table
if ( ! empty($table)) if ( ! empty($table))
@ -689,12 +689,12 @@ class QueryBuilder implements QueryBuilderInterface {
* Convenience method for get() with a where clause * Convenience method for get() with a where clause
* *
* @param string $table * @param string $table
* @param array $where * @param mixed $where
* @param int|bool $limit * @param int|bool $limit
* @param int|bool $offset * @param int|bool $offset
* @return PDOStatement * @return PDOStatement
*/ */
public function getWhere($table, $where=[], $limit=FALSE, $offset=FALSE): PDOStatement public function getWhere(string $table, $where=[], $limit=FALSE, $offset=FALSE): ?PDOStatement
{ {
// Create the where clause // Create the where clause
$this->where($where); $this->where($where);
@ -709,7 +709,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $table * @param string $table
* @return int * @return int
*/ */
public function countAll($table): int public function countAll(string $table): int
{ {
$sql = 'SELECT * FROM '.$this->driver->quoteTable($table); $sql = 'SELECT * FROM '.$this->driver->quoteTable($table);
$res = $this->driver->query($sql); $res = $this->driver->query($sql);
@ -745,7 +745,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param mixed $data * @param mixed $data
* @return PDOStatement * @return PDOStatement
*/ */
public function insert($table, $data=[]): PDOStatement public function insert(string $table, $data=[]): ?PDOStatement
{ {
if ( ! empty($data)) if ( ! empty($data))
{ {
@ -762,10 +762,10 @@ class QueryBuilder implements QueryBuilderInterface {
* @param array $data * @param array $data
* @return PDOStatement * @return PDOStatement
*/ */
public function insertBatch($table, $data=[]): PDOStatement public function insertBatch(string $table, $data=[]): ?PDOStatement
{ {
// Get the generated values and sql string // Get the generated values and sql string
list($sql, $data) = $this->driver->insertBatch($table, $data); [$sql, $data] = $this->driver->insertBatch($table, $data);
return $sql !== NULL return $sql !== NULL
? $this->_run('', $table, $sql, $data) ? $this->_run('', $table, $sql, $data)
@ -779,7 +779,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param mixed $data * @param mixed $data
* @return PDOStatement * @return PDOStatement
*/ */
public function update($table, $data=[]): PDOStatement public function update(string $table, $data=[]): PDOStatement
{ {
if ( ! empty($data)) if ( ! empty($data))
{ {
@ -796,9 +796,9 @@ class QueryBuilder implements QueryBuilderInterface {
* @param string $table * @param string $table
* @param array|object $data * @param array|object $data
* @param string $where * @param string $where
* @return int|null * @return PDOStatement|null
*/ */
public function updateBatch($table, $data, $where) public function updateBatch(string $table, $data, $where): ?PDOStatement
{ {
// Get the generated values and sql string // Get the generated values and sql string
list($sql, $data) = $this->driver->updateBatch($table, $data, $where); list($sql, $data) = $this->driver->updateBatch($table, $data, $where);
@ -815,7 +815,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param array $data * @param array $data
* @return \PDOStatement|null * @return \PDOStatement|null
*/ */
public function replace($table, $data=[]) public function replace(string $table, $data=[]): ?PDOStatement
{ {
if ( ! empty($data)) if ( ! empty($data))
{ {
@ -832,7 +832,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param mixed $where * @param mixed $where
* @return PDOStatement * @return PDOStatement
*/ */
public function delete($table, $where=''): PDOStatement public function delete(string $table, $where=''): ?PDOStatement
{ {
// Set the where clause // Set the where clause
if ( ! empty($where)) if ( ! empty($where))
@ -916,8 +916,6 @@ class QueryBuilder implements QueryBuilderInterface {
$this->explain = FALSE; $this->explain = FALSE;
} }
/** /**
* Method to simplify select_ methods * Method to simplify select_ methods
* *
@ -1144,7 +1142,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param boolean $reset * @param boolean $reset
* @return PDOStatement * @return PDOStatement
*/ */
protected function _run(string $type, string $table, $sql=NULL, $vals=NULL, bool $reset=TRUE): PDOStatement protected function _run(string $type, string $table, string $sql=NULL, array $vals=NULL, bool $reset=TRUE): PDOStatement
{ {
if ($sql === NULL) if ($sql === NULL)
{ {
@ -1153,7 +1151,7 @@ class QueryBuilder implements QueryBuilderInterface {
if ($vals === NULL) if ($vals === NULL)
{ {
$vals = array_merge($this->state->getValues(), (array) $this->state->getWhereValues()); $vals = array_merge($this->state->getValues(), $this->state->getWhereValues());
} }
$startTime = microtime(TRUE); $startTime = microtime(TRUE);
@ -1185,7 +1183,7 @@ class QueryBuilder implements QueryBuilderInterface {
* @param int $totalTime * @param int $totalTime
* @return void * @return void
*/ */
protected function _appendQuery($vals, string $sql, int $totalTime) protected function _appendQuery(array $vals = NULL, string $sql, int $totalTime)
{ {
$evals = \is_array($vals) ? $vals : []; $evals = \is_array($vals) ? $vals : [];
$esql = str_replace('?', "%s", $sql); $esql = str_replace('?', "%s", $sql);

View File

@ -18,9 +18,6 @@ use PDOStatement;
/** /**
* Interface defining the Query Builder class * Interface defining the Query Builder class
*
* @package Query
* @subpackage QueryBuilder
*/ */
interface QueryBuilderInterface { interface QueryBuilderInterface {
@ -36,8 +33,6 @@ interface QueryBuilderInterface {
*/ */
public function select(string $fields): QueryBuilderInterface; public function select(string $fields): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Selects the maximum value of a field from a query * Selects the maximum value of a field from a query
* *
@ -47,8 +42,6 @@ interface QueryBuilderInterface {
*/ */
public function selectMax(string $field, $as=FALSE): QueryBuilderInterface; public function selectMax(string $field, $as=FALSE): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Selects the minimum value of a field from a query * Selects the minimum value of a field from a query
* *
@ -58,8 +51,6 @@ interface QueryBuilderInterface {
*/ */
public function selectMin(string $field, $as=FALSE): QueryBuilderInterface; public function selectMin(string $field, $as=FALSE): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Selects the average value of a field from a query * Selects the average value of a field from a query
* *
@ -69,8 +60,6 @@ interface QueryBuilderInterface {
*/ */
public function selectAvg(string $field, $as=FALSE): QueryBuilderInterface; public function selectAvg(string $field, $as=FALSE): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Selects the sum of a field from a query * Selects the sum of a field from a query
* *
@ -80,8 +69,6 @@ interface QueryBuilderInterface {
*/ */
public function selectSum(string $field, $as=FALSE): QueryBuilderInterface; public function selectSum(string $field, $as=FALSE): QueryBuilderInterface;
// --------------------------------------------------------------------------q
/** /**
* Adds the 'distinct' keyword to a query * Adds the 'distinct' keyword to a query
* *
@ -89,8 +76,6 @@ interface QueryBuilderInterface {
*/ */
public function distinct(): QueryBuilderInterface; public function distinct(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Shows the query plan for the query * Shows the query plan for the query
* *
@ -98,15 +83,13 @@ interface QueryBuilderInterface {
*/ */
public function explain(): QueryBuilderInterface; public function explain(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Specify the database table to select from * Specify the database table to select from
* *
* @param string $tblname * @param string $tblname
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function from($tblname): QueryBuilderInterface; public function from(string $tblname): QueryBuilderInterface;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! 'Like' methods // ! 'Like' methods
@ -116,47 +99,41 @@ interface QueryBuilderInterface {
* Creates a Like clause in the sql statement * Creates a Like clause in the sql statement
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function like($field, $val, $pos='both'): QueryBuilderInterface; public function like(string $field, $values, string $pos='both'): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Generates an OR Like clause * Generates an OR Like clause
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orLike($field, $val, $pos='both'): QueryBuilderInterface; public function orLike(string $field, $values, string $pos='both'): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Generates a NOT LIKE clause * Generates a NOT LIKE clause
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function notLike($field, $val, $pos='both'): QueryBuilderInterface; public function notLike(string $field, $values, string $pos='both'): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Generates a OR NOT LIKE clause * Generates a OR NOT LIKE clause
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @param string $pos * @param string $pos
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orNotLike($field, $val, $pos='both'): QueryBuilderInterface; public function orNotLike(string $field, $values, string $pos='both'): QueryBuilderInterface;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! Having methods // ! Having methods
@ -166,21 +143,19 @@ interface QueryBuilderInterface {
* Generates a 'Having' clause * Generates a 'Having' clause
* *
* @param mixed $key * @param mixed $key
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function having($key, $val=[]): QueryBuilderInterface; public function having($key, $values=[]): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Generates a 'Having' clause prefixed with 'OR' * Generates a 'Having' clause prefixed with 'OR'
* *
* @param mixed $key * @param mixed $key
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orHaving($key, $val=[]): QueryBuilderInterface; public function orHaving($key, $values=[]): QueryBuilderInterface;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! 'Where' methods // ! 'Where' methods
@ -192,66 +167,56 @@ interface QueryBuilderInterface {
* passed array with key / value pairs * passed array with key / value pairs
* *
* @param mixed $key * @param mixed $key
* @param mixed $val * @param mixed $values
* @param bool $escape * @param bool $escape
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function where($key, $val=[], $escape = NULL): QueryBuilderInterface; public function where($key, $values=[], $escape = NULL): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Where clause prefixed with "OR" * Where clause prefixed with "OR"
* *
* @param string $key * @param string $key
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orWhere($key, $val=[]): QueryBuilderInterface; public function orWhere($key, $values=[]): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Where clause with 'IN' statement * Where clause with 'IN' statement
* *
* @param mixed $field * @param mixed $field
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function whereIn($field, $val=[]): QueryBuilderInterface; public function whereIn($field, $values=[]): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Where in statement prefixed with "or" * Where in statement prefixed with "or"
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orWhereIn($field, $val=[]): QueryBuilderInterface; public function orWhereIn($field, $values=[]): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* WHERE NOT IN (FOO) clause * WHERE NOT IN (FOO) clause
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function whereNotIn($field, $val=[]): QueryBuilderInterface; public function whereNotIn($field, $values=[]): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* OR WHERE NOT IN (FOO) clause * OR WHERE NOT IN (FOO) clause
* *
* @param string $field * @param string $field
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orWhereNotIn($field, $val=[]): QueryBuilderInterface; public function orWhereNotIn($field, $values=[]): QueryBuilderInterface;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! Other Query Modifier methods // ! Other Query Modifier methods
@ -261,12 +226,10 @@ interface QueryBuilderInterface {
* Sets values for inserts / updates / deletes * Sets values for inserts / updates / deletes
* *
* @param mixed $key * @param mixed $key
* @param mixed $val * @param mixed $values
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function set($key, $val = NULL): QueryBuilderInterface; public function set($key, $values = NULL): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Creates a join phrase in a compiled query * Creates a join phrase in a compiled query
@ -276,9 +239,7 @@ interface QueryBuilderInterface {
* @param string $type * @param string $type
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function join($table, $condition, $type=''): QueryBuilderInterface; public function join(string $table, string $condition, string $type=''): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Group the results by the selected field(s) * Group the results by the selected field(s)
@ -288,8 +249,6 @@ interface QueryBuilderInterface {
*/ */
public function groupBy($field): QueryBuilderInterface; public function groupBy($field): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Order the results by the selected field(s) * Order the results by the selected field(s)
* *
@ -297,9 +256,7 @@ interface QueryBuilderInterface {
* @param string $type * @param string $type
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function orderBy($field, $type=""): QueryBuilderInterface; public function orderBy(string $field, string $type=''): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Set a limit on the current sql statement * Set a limit on the current sql statement
@ -308,7 +265,7 @@ interface QueryBuilderInterface {
* @param int|bool $offset * @param int|bool $offset
* @return QueryBuilderInterface * @return QueryBuilderInterface
*/ */
public function limit($limit, $offset=FALSE): QueryBuilderInterface; public function limit(int $limit, $offset=FALSE): QueryBuilderInterface;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! Query Grouping Methods // ! Query Grouping Methods
@ -321,8 +278,6 @@ interface QueryBuilderInterface {
*/ */
public function groupStart(): QueryBuilderInterface; public function groupStart(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Adds a paren to the current query for query grouping, * Adds a paren to the current query for query grouping,
* prefixed with 'NOT' * prefixed with 'NOT'
@ -331,8 +286,6 @@ interface QueryBuilderInterface {
*/ */
public function notGroupStart(): QueryBuilderInterface; public function notGroupStart(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Adds a paren to the current query for query grouping, * Adds a paren to the current query for query grouping,
* prefixed with 'OR' * prefixed with 'OR'
@ -341,8 +294,6 @@ interface QueryBuilderInterface {
*/ */
public function orGroupStart(): QueryBuilderInterface; public function orGroupStart(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Adds a paren to the current query for query grouping, * Adds a paren to the current query for query grouping,
* prefixed with 'OR NOT' * prefixed with 'OR NOT'
@ -351,8 +302,6 @@ interface QueryBuilderInterface {
*/ */
public function orNotGroupStart(): QueryBuilderInterface; public function orNotGroupStart(): QueryBuilderInterface;
// --------------------------------------------------------------------------
/** /**
* Ends a query group * Ends a query group
* *
@ -373,9 +322,7 @@ interface QueryBuilderInterface {
* @param int|bool $offset * @param int|bool $offset
* @return PDOStatement * @return PDOStatement
*/ */
public function get($table='', $limit=FALSE, $offset=FALSE): PDOStatement; public function get(string $table='', $limit=FALSE, $offset=FALSE): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Convenience method for get() with a where clause * Convenience method for get() with a where clause
@ -386,9 +333,7 @@ interface QueryBuilderInterface {
* @param int|bool $offset * @param int|bool $offset
* @return PDOStatement * @return PDOStatement
*/ */
public function getWhere($table, $where=[], $limit=FALSE, $offset=FALSE): PDOStatement; public function getWhere(string $table, $where=[], $limit=FALSE, $offset=FALSE): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Retrieve the number of rows in the selected table * Retrieve the number of rows in the selected table
@ -396,9 +341,7 @@ interface QueryBuilderInterface {
* @param string $table * @param string $table
* @return int * @return int
*/ */
public function countAll($table): int; public function countAll(string $table): int;
// --------------------------------------------------------------------------
/** /**
* Retrieve the number of results for the generated query - used * Retrieve the number of results for the generated query - used
@ -410,8 +353,6 @@ interface QueryBuilderInterface {
*/ */
public function countAllResults(string $table='', bool $reset=TRUE): int; public function countAllResults(string $table='', bool $reset=TRUE): int;
// --------------------------------------------------------------------------
/** /**
* Creates an insert clause, and executes it * Creates an insert clause, and executes it
* *
@ -419,31 +360,25 @@ interface QueryBuilderInterface {
* @param mixed $data * @param mixed $data
* @return PDOStatement * @return PDOStatement
*/ */
public function insert($table, $data=[]): PDOStatement; public function insert(string $table, $data=[]): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Creates and executes a batch insertion query * Creates and executes a batch insertion query
* *
* @param string $table * @param string $table
* @param array $data * @param array $data
* @return \PDOStatement|null * @return PDOStatement
*/ */
public function insertBatch($table, $data=[]); public function insertBatch(string $table, $data=[]): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Insertion with automatic overwrite, rather than attempted duplication * Insertion with automatic overwrite, rather than attempted duplication
* *
* @param string $table * @param string $table
* @param array $data * @param array $data
* @return \PDOStatement|null * @return PDOStatement
*/ */
public function replace($table, $data=[]); public function replace(string $table, $data=[]): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Creates an update clause, and executes it * Creates an update clause, and executes it
@ -452,9 +387,7 @@ interface QueryBuilderInterface {
* @param mixed $data * @param mixed $data
* @return PDOStatement * @return PDOStatement
*/ */
public function update($table, $data=[]): PDOStatement; public function update(string $table, $data=[]): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Creates a batch update, and executes it. * Creates a batch update, and executes it.
@ -463,11 +396,9 @@ interface QueryBuilderInterface {
* @param string $table * @param string $table
* @param array|object $data * @param array|object $data
* @param string $where * @param string $where
* @return int|null * @return PDOStatement
*/ */
public function updateBatch($table, $data, $where); public function updateBatch(string $table, $data, $where): ?PDOStatement;
// --------------------------------------------------------------------------
/** /**
* Deletes data from a table * Deletes data from a table
@ -476,7 +407,7 @@ interface QueryBuilderInterface {
* @param mixed $where * @param mixed $where
* @return PDOStatement * @return PDOStatement
*/ */
public function delete($table, $where=''): PDOStatement; public function delete(string $table, $where=''): ?PDOStatement;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// ! SQL Returning Methods // ! SQL Returning Methods

View File

@ -6,12 +6,13 @@
* *
* PHP version 7.1 * PHP version 7.1
* *
* @package Query * @package Query
* @author Timothy J. Warren <tim@timshomepage.net> * @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2012 - 2018 Timothy J. Warren * @copyright 2012 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://git.timshomepage.net/aviat4ion/Query * @link https://git.timshomepage.net/aviat4ion/Query
*/ */
namespace Query; namespace Query;
/** /**
@ -92,7 +93,7 @@ class State {
/** /**
* Value for limit string * Value for limit string
* @var int * @var integer
*/ */
protected $limit; protected $limit;
@ -123,22 +124,20 @@ class State {
*/ */
protected $havingMap = []; protected $havingMap = [];
// -------------------------------------------------------------------------- /**
* @param string $str
/** * @return State
* @param string $str */
* @return State
*/
public function setSelectString(string $str): self public function setSelectString(string $str): self
{ {
$this->selectString = $str; $this->selectString = $str;
return $this; return $this;
} }
/** /**
* @return string * @return string
*/ */
public function getSelectString(): string public function getSelectString(): string
{ {
return $this->selectString; return $this->selectString;
} }
@ -147,7 +146,7 @@ class State {
* @param string $str * @param string $str
* @return State * @return State
*/ */
public function appendSelectString(string $str): self public function appendSelectString(string $str): self
{ {
$this->selectString .= $str; $this->selectString .= $str;
return $this; return $this;

View File

@ -13,14 +13,11 @@
* @link https://git.timshomepage.net/aviat4ion/Query * @link https://git.timshomepage.net/aviat4ion/Query
*/ */
use Query\{ use Query\{
ConnectionManager, ConnectionManager,
QueryBuilderInterface QueryBuilderInterface
}; };
// --------------------------------------------------------------------------
/** /**
* Global functions that don't really fit anywhere else * Global functions that don't really fit anywhere else
*/ */
@ -36,8 +33,6 @@ function mb_trim(string $string): string
return preg_replace('/(^\s+)|(\s+$)/u', '', $string); return preg_replace('/(^\s+)|(\s+$)/u', '', $string);
} }
// --------------------------------------------------------------------------
/** /**
* Filter out db rows into one array * Filter out db rows into one array
* *
@ -57,8 +52,6 @@ function dbFilter(array $array, $index): array
return $newArray; return $newArray;
} }
// --------------------------------------------------------------------------
/** /**
* Zip a set of arrays together on common keys * Zip a set of arrays together on common keys
* *
@ -87,8 +80,6 @@ function arrayZipper(array $zipperInput): array
return $output; return $output;
} }
// --------------------------------------------------------------------------
/** /**
* Determine whether a value in the passed array matches the pattern * Determine whether a value in the passed array matches the pattern
* passed * passed
@ -115,8 +106,6 @@ function regexInArray(array $array, string $pattern): bool
return FALSE; return FALSE;
} }
// --------------------------------------------------------------------------
/** /**
* Connection function * Connection function
* *

View File

@ -12,9 +12,8 @@
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://git.timshomepage.net/aviat4ion/Query * @link https://git.timshomepage.net/aviat4ion/Query
*/ */
namespace Query\Tests;
// -------------------------------------------------------------------------- namespace Query\Tests;
/** /**
* Parent Database Test Class * Parent Database Test Class
@ -28,15 +27,11 @@ abstract class BaseDriverTest extends TestCase {
abstract public function testConnection(); abstract public function testConnection();
// --------------------------------------------------------------------------
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
self::$db = NULL; self::$db = NULL;
} }
// --------------------------------------------------------------------------
public function testGetTables() public function testGetTables()
{ {
$tables = self::$db->getTables(); $tables = self::$db->getTables();
@ -44,8 +39,6 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue( ! empty($tables)); $this->assertTrue( ! empty($tables));
} }
// --------------------------------------------------------------------------
public function testGetSystemTables() public function testGetSystemTables()
{ {
$tables = self::$db->getSystemTables(); $tables = self::$db->getSystemTables();
@ -53,16 +46,12 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue( ! empty($tables)); $this->assertTrue( ! empty($tables));
} }
// --------------------------------------------------------------------------
public function testBackupData() public function testBackupData()
{ {
$this->assertTrue(is_string(self::$db->getUtil()->backupData(array('create_delete', FALSE)))); $this->assertTrue(is_string(self::$db->getUtil()->backupData(array('create_delete', FALSE))));
$this->assertTrue(is_string(self::$db->getUtil()->backupData(array('create_delete', TRUE)))); $this->assertTrue(is_string(self::$db->getUtil()->backupData(array('create_delete', TRUE))));
} }
// --------------------------------------------------------------------------
public function testGetColumns() public function testGetColumns()
{ {
$cols = self::$db->getColumns('test'); $cols = self::$db->getColumns('test');
@ -70,8 +59,6 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue( ! empty($cols)); $this->assertTrue( ! empty($cols));
} }
// --------------------------------------------------------------------------
public function testGetTypes() public function testGetTypes()
{ {
$types = self::$db->getTypes(); $types = self::$db->getTypes();
@ -79,8 +66,6 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue( ! empty($types)); $this->assertTrue( ! empty($types));
} }
// --------------------------------------------------------------------------
public function testGetFKs() public function testGetFKs()
{ {
$expected = array(array( $expected = array(array(
@ -95,16 +80,12 @@ abstract class BaseDriverTest extends TestCase {
$this->assertEqual($expected, $keys); $this->assertEqual($expected, $keys);
} }
// --------------------------------------------------------------------------
public function testGetIndexes() public function testGetIndexes()
{ {
$keys = self::$db->getIndexes('test'); $keys = self::$db->getIndexes('test');
$this->assertTrue(is_array($keys)); $this->assertTrue(is_array($keys));
} }
// --------------------------------------------------------------------------
public function testGetViews() public function testGetViews()
{ {
$views = self::$db->getViews(); $views = self::$db->getViews();
@ -113,8 +94,6 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue(is_array($views)); $this->assertTrue(is_array($views));
} }
// --------------------------------------------------------------------------
public function testGetTriggers() public function testGetTriggers()
{ {
// @TODO standardize trigger output for different databases // @TODO standardize trigger output for different databases
@ -123,8 +102,6 @@ abstract class BaseDriverTest extends TestCase {
$this->assertTrue(is_array($triggers)); $this->assertTrue(is_array($triggers));
} }
// --------------------------------------------------------------------------
public function testGetSequences() public function testGetSequences()
{ {
$seqs = self::$db->getSequences(); $seqs = self::$db->getSequences();
@ -138,16 +115,12 @@ abstract class BaseDriverTest extends TestCase {
$this->assertEqual($expected, $seqs); $this->assertEqual($expected, $seqs);
} }
// --------------------------------------------------------------------------
public function testGetProcedures() public function testGetProcedures()
{ {
$procedures = self::$db->getProcedures(); $procedures = self::$db->getProcedures();
$this->assertTrue(is_array($procedures)); $this->assertTrue(is_array($procedures));
} }
// --------------------------------------------------------------------------
public function testGetFunctions() public function testGetFunctions()
{ {
$funcs = self::$db->getFunctions(); $funcs = self::$db->getFunctions();

View File

@ -26,8 +26,6 @@ class ConnectionManagerTest extends TestCase {
self::$instance = ConnectionManager::getInstance(); self::$instance = ConnectionManager::getInstance();
} }
// --------------------------------------------------------------------------
public function testNoClone() public function testNoClone()
{ {
$this->expectException('DomainException'); $this->expectException('DomainException');
@ -36,8 +34,6 @@ class ConnectionManagerTest extends TestCase {
$this->assertNull($clone); $this->assertNull($clone);
} }
// --------------------------------------------------------------------------
public function testNoSerialize() public function testNoSerialize()
{ {
$this->expectException(DomainException::class); $this->expectException(DomainException::class);
@ -49,8 +45,6 @@ class ConnectionManagerTest extends TestCase {
self::$instance->__sleep(); self::$instance->__sleep();
} }
// --------------------------------------------------------------------------
public function testNoUnserialize() public function testNoUnserialize()
{ {
$this->expectException(DomainException::class); $this->expectException(DomainException::class);
@ -58,8 +52,6 @@ class ConnectionManagerTest extends TestCase {
self::$instance->__wakeup(); self::$instance->__wakeup();
} }
// --------------------------------------------------------------------------
public function testParseParams() public function testParseParams()
{ {
$params = (object) array( $params = (object) array(
@ -80,8 +72,6 @@ class ConnectionManagerTest extends TestCase {
$this->assertEqual($expected, self::$instance->parseParams($params)); $this->assertEqual($expected, self::$instance->parseParams($params));
} }
// --------------------------------------------------------------------------
public function testConnect() public function testConnect()
{ {
$params = (object) array( $params = (object) array(
@ -101,8 +91,6 @@ class ConnectionManagerTest extends TestCase {
$this->assertEqual($conn, self::$instance->getConnection()); $this->assertEqual($conn, self::$instance->getConnection());
} }
// --------------------------------------------------------------------------
public function testGetConnection() public function testGetConnection()
{ {
$params = (object) array( $params = (object) array(

View File

@ -14,9 +14,6 @@
*/ */
namespace Query\Tests; namespace Query\Tests;
// --------------------------------------------------------------------------
/** /**
* CoreTest class - Compatibility and core functionality tests * CoreTest class - Compatibility and core functionality tests
* *
@ -36,8 +33,6 @@ class CoreTest extends TestCase {
$this->assertTrue(PHP_VERSION_ID >= 70000); $this->assertTrue(PHP_VERSION_ID >= 70000);
} }
// --------------------------------------------------------------------------
/** /**
* TestHasPDO function. * TestHasPDO function.
* *

View File

@ -22,7 +22,6 @@ use TypeError;
/** /**
* MySQLTest class. * MySQLTest class.
* *
* @extends DBTest
* @requires extension pdo_mysql * @requires extension pdo_mysql
*/ */
class MySQLDriverTest extends BaseDriverTest { class MySQLDriverTest extends BaseDriverTest {
@ -47,22 +46,16 @@ class MySQLDriverTest extends BaseDriverTest {
self::$db->setTablePrefix('create_'); self::$db->setTablePrefix('create_');
} }
// --------------------------------------------------------------------------
public function testExists() public function testExists()
{ {
$this->assertTrue(\in_array('mysql', PDO::getAvailableDrivers(), TRUE)); $this->assertTrue(\in_array('mysql', PDO::getAvailableDrivers(), TRUE));
} }
// --------------------------------------------------------------------------
public function testConnection() public function testConnection()
{ {
$this->assertIsA(self::$db, Driver::class); $this->assertIsA(self::$db, Driver::class);
} }
// --------------------------------------------------------------------------
public function testCreateTable() public function testCreateTable()
{ {
self::$db->exec(file_get_contents(QTEST_DIR.'/db_files/mysql.sql')); self::$db->exec(file_get_contents(QTEST_DIR.'/db_files/mysql.sql'));
@ -101,8 +94,6 @@ class MySQLDriverTest extends BaseDriverTest {
} }
// --------------------------------------------------------------------------
public function testTruncate() public function testTruncate()
{ {
self::$db->truncate('test'); self::$db->truncate('test');
@ -112,8 +103,6 @@ class MySQLDriverTest extends BaseDriverTest {
$this->assertEquals(0, self::$db->countAll('join')); $this->assertEquals(0, self::$db->countAll('join'));
} }
// --------------------------------------------------------------------------
public function testPreparedStatements() public function testPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
@ -128,8 +117,6 @@ SQL;
} }
// --------------------------------------------------------------------------
public function testBadPreparedStatement() public function testBadPreparedStatement()
{ {
$this->expectException(TypeError::class); $this->expectException(TypeError::class);
@ -143,8 +130,6 @@ SQL;
} }
// --------------------------------------------------------------------------
public function testPrepareExecute() public function testPrepareExecute()
{ {
$sql = <<<SQL $sql = <<<SQL
@ -159,8 +144,6 @@ SQL;
} }
// --------------------------------------------------------------------------
public function testCommitTransaction() public function testCommitTransaction()
{ {
$res = self::$db->beginTransaction(); $res = self::$db->beginTransaction();
@ -172,8 +155,6 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testRollbackTransaction() public function testRollbackTransaction()
{ {
$res = self::$db->beginTransaction(); $res = self::$db->beginTransaction();
@ -185,26 +166,18 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testGetSchemas() public function testGetSchemas()
{ {
$this->assertNull(self::$db->getSchemas()); $this->assertNull(self::$db->getSchemas());
} }
// --------------------------------------------------------------------------
public function testGetSequences() public function testGetSequences()
{ {
$this->assertNull(self::$db->getSequences()); $this->assertNull(self::$db->getSequences());
} }
// --------------------------------------------------------------------------
public function testBackup() public function testBackup()
{ {
$this->assertTrue(is_string(self::$db->getUtil()->backupStructure())); $this->assertTrue(is_string(self::$db->getUtil()->backupStructure()));
} }
} }

View File

@ -17,8 +17,6 @@ namespace Query\Tests\Drivers\MySQL;
use PDO; use PDO;
use Query\Tests\BaseQueryBuilderTest; use Query\Tests\BaseQueryBuilderTest;
// --------------------------------------------------------------------------
/** /**
* @requires extension pdo_mysql * @requires extension pdo_mysql
*/ */
@ -51,15 +49,11 @@ class MySQLQueryBuilderTest extends BaseQueryBuilderTest {
self::$db = Query($params); self::$db = Query($params);
} }
// --------------------------------------------------------------------------
public function testExists() public function testExists()
{ {
$this->assertTrue(\in_array('mysql', PDO::getAvailableDrivers(), TRUE)); $this->assertTrue(\in_array('mysql', PDO::getAvailableDrivers(), TRUE));
} }
// --------------------------------------------------------------------------
public function testQueryExplain() public function testQueryExplain()
{ {
$query = self::$db->select('id, key as k, val') $query = self::$db->select('id, key as k, val')

View File

@ -12,11 +12,9 @@
* @license http://www.opensource.org/licenses/mit-license.html MIT License * @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://git.timshomepage.net/aviat4ion/Query * @link https://git.timshomepage.net/aviat4ion/Query
*/ */
namespace Query\Tests\Drivers\PgSQL; namespace Query\Tests\Drivers\PgSQL;
// --------------------------------------------------------------------------
use InvalidArgumentException;
use PDO; use PDO;
use Query\Drivers\Pgsql\Driver; use Query\Drivers\Pgsql\Driver;
use Query\Tests\BaseDriverTest; use Query\Tests\BaseDriverTest;
@ -57,16 +55,12 @@ class PgSQLDriverTest extends BaseDriverTest {
self::$db->setTablePrefix('create_'); self::$db->setTablePrefix('create_');
} }
// --------------------------------------------------------------------------
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));
} }
// --------------------------------------------------------------------------
public function testConnection() public function testConnection()
{ {
if (empty(self::$db)) return; if (empty(self::$db)) return;
@ -74,8 +68,6 @@ class PgSQLDriverTest extends BaseDriverTest {
$this->assertIsA(self::$db, Driver::class); $this->assertIsA(self::$db, Driver::class);
} }
// --------------------------------------------------------------------------
public function testCreateTable() public function testCreateTable()
{ {
self::$db->exec(file_get_contents(QTEST_DIR.'/db_files/pgsql.sql')); self::$db->exec(file_get_contents(QTEST_DIR.'/db_files/pgsql.sql'));
@ -126,8 +118,6 @@ class PgSQLDriverTest extends BaseDriverTest {
} }
// --------------------------------------------------------------------------
public function testTruncate() public function testTruncate()
{ {
self::$db->truncate('test'); self::$db->truncate('test');
@ -137,8 +127,6 @@ class PgSQLDriverTest extends BaseDriverTest {
$this->assertEquals(0, self::$db->countAll('join')); $this->assertEquals(0, self::$db->countAll('join'));
} }
// --------------------------------------------------------------------------
public function testPreparedStatements() public function testPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
@ -159,8 +147,6 @@ SQL;
], $res); ], $res);
} }
// --------------------------------------------------------------------------
public function testBadPreparedStatement() public function testBadPreparedStatement()
{ {
$this->expectException(TypeError::class); $this->expectException(TypeError::class);
@ -173,8 +159,6 @@ SQL;
self::$db->prepareQuery($sql, 'foo'); self::$db->prepareQuery($sql, 'foo');
} }
// --------------------------------------------------------------------------
public function testPrepareExecute() public function testPrepareExecute()
{ {
if (empty(self::$db)) return; if (empty(self::$db)) return;
@ -197,8 +181,6 @@ SQL;
], $res); ], $res);
} }
// --------------------------------------------------------------------------
public function testCommitTransaction() public function testCommitTransaction()
{ {
if (empty(self::$db)) return; if (empty(self::$db)) return;
@ -212,8 +194,6 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testRollbackTransaction() public function testRollbackTransaction()
{ {
if (empty(self::$db)) return; if (empty(self::$db)) return;
@ -227,22 +207,16 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testGetSchemas() public function testGetSchemas()
{ {
$this->assertTrue(is_array(self::$db->getSchemas())); $this->assertTrue(is_array(self::$db->getSchemas()));
} }
// --------------------------------------------------------------------------
public function testGetDBs() public function testGetDBs()
{ {
$this->assertTrue(is_array(self::$db->getDbs())); $this->assertTrue(is_array(self::$db->getDbs()));
} }
// --------------------------------------------------------------------------
public function testGetFunctions() public function testGetFunctions()
{ {
$this->assertNull(self::$db->getFunctions()); $this->assertNull(self::$db->getFunctions());

View File

@ -17,8 +17,6 @@ namespace Query\Tests\Drivers\PgSQL;
use PDO; use PDO;
use Query\Tests\BaseQueryBuilderTest; use Query\Tests\BaseQueryBuilderTest;
// --------------------------------------------------------------------------
/** /**
* @requires extension pdo_pgsql * @requires extension pdo_pgsql
*/ */
@ -58,19 +56,15 @@ class PgSQLQueryBuilderTest extends BaseQueryBuilderTest {
// If the database isn't installed, skip the tests // If the database isn't installed, skip the tests
if ( ! \in_array('pgsql', PDO::getAvailableDrivers(), TRUE)) if ( ! \in_array('pgsql', PDO::getAvailableDrivers(), TRUE))
{ {
$this->markTestSkipped("Postgres extension for PDO not loaded"); $this->markTestSkipped('Postgres extension for PDO not loaded');
} }
} }
// --------------------------------------------------------------------------
public function testExists() public function testExists()
{ {
$this->assertTrue(\in_array('pgsql', PDO::getAvailableDrivers(), TRUE)); $this->assertTrue(\in_array('pgsql', PDO::getAvailableDrivers(), TRUE));
} }
// --------------------------------------------------------------------------
public function testQueryExplain() public function testQueryExplain()
{ {
$query = self::$db->select('id, key as k, val') $query = self::$db->select('id, key as k, val')

View File

@ -18,8 +18,6 @@ use PDO;
use Query\Drivers\Sqlite\Driver; use Query\Drivers\Sqlite\Driver;
use Query\Tests\BaseDriverTest; use Query\Tests\BaseDriverTest;
// --------------------------------------------------------------------------
/** /**
* SQLiteTest class. * SQLiteTest class.
* *
@ -64,8 +62,6 @@ class SQLiteDriverTest extends BaseDriverTest {
$this->assertTrue(\in_array('create_delete', $dbs, TRUE)); $this->assertTrue(\in_array('create_delete', $dbs, TRUE));
} }
// --------------------------------------------------------------------------
/*public function testBackupData() /*public function testBackupData()
{ {
$sql = mb_trim(self::$db->getUtil()->backupData(array('create_join', 'create_test'))); $sql = mb_trim(self::$db->getUtil()->backupData(array('create_join', 'create_test')));
@ -83,8 +79,6 @@ SQL;
$this->assertEqual($expectedArray, $sqlArray); $this->assertEqual($expectedArray, $sqlArray);
}*/ }*/
// --------------------------------------------------------------------------
public function testBackupStructure() public function testBackupStructure()
{ {
$sql = mb_trim(self::$db->getUtil()->backupStructure()); $sql = mb_trim(self::$db->getUtil()->backupStructure());
@ -159,8 +153,6 @@ SQL;
$this->assertEqual($expectedArray, $resultArray); $this->assertEqual($expectedArray, $resultArray);
} }
// --------------------------------------------------------------------------
public function testDeleteTable() public function testDeleteTable()
{ {
$sql = self::$db->getUtil()->deleteTable('create_delete'); $sql = self::$db->getUtil()->deleteTable('create_delete');
@ -188,16 +180,12 @@ SQL;
unset($db); unset($db);
} }
// --------------------------------------------------------------------------
public function testTruncate() public function testTruncate()
{ {
self::$db->truncate('create_test'); self::$db->truncate('create_test');
$this->assertEquals(0, self::$db->countAll('create_test')); $this->assertEquals(0, self::$db->countAll('create_test'));
} }
// --------------------------------------------------------------------------
public function testPreparedStatements() public function testPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
@ -218,8 +206,6 @@ SQL;
], $res); ], $res);
} }
// --------------------------------------------------------------------------
public function testPrepareExecute() public function testPrepareExecute()
{ {
$sql = <<<SQL $sql = <<<SQL
@ -240,8 +226,6 @@ SQL;
], $res); ], $res);
} }
// --------------------------------------------------------------------------
public function testCommitTransaction() public function testCommitTransaction()
{ {
$res = self::$db->beginTransaction(); $res = self::$db->beginTransaction();
@ -253,8 +237,6 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testRollbackTransaction() public function testRollbackTransaction()
{ {
$res = self::$db->beginTransaction(); $res = self::$db->beginTransaction();
@ -266,15 +248,11 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function testGetDBs() public function testGetDBs()
{ {
$this->assertTrue(is_array(self::$db->getDbs())); $this->assertTrue(is_array(self::$db->getDbs()));
} }
// --------------------------------------------------------------------------
public function testGetSchemas() public function testGetSchemas()
{ {
$this->assertNull(self::$db->getSchemas()); $this->assertNull(self::$db->getSchemas());
@ -296,30 +274,22 @@ SQL;
$this->assertEqual(NULL, $sql); $this->assertEqual(NULL, $sql);
} }
// --------------------------------------------------------------------------
public function testGetSystemTables() public function testGetSystemTables()
{ {
$sql = self::$db->getSystemTables(); $sql = self::$db->getSystemTables();
$this->assertTrue(\is_array($sql)); $this->assertTrue(\is_array($sql));
} }
// --------------------------------------------------------------------------
public function testGetSequences() public function testGetSequences()
{ {
$this->assertNull(self::$db->getSequences()); $this->assertNull(self::$db->getSequences());
} }
// --------------------------------------------------------------------------
public function testGetFunctions() public function testGetFunctions()
{ {
$this->assertNull(self::$db->getFunctions()); $this->assertNull(self::$db->getFunctions());
} }
// --------------------------------------------------------------------------
public function testGetProcedures() public function testGetProcedures()
{ {
$this->assertNull(self::$db->getProcedures()); $this->assertNull(self::$db->getProcedures());

View File

@ -17,8 +17,6 @@ namespace Query\Tests\Drivers\SQLite;
use PDO; use PDO;
use Query\Tests\BaseQueryBuilderTest; use Query\Tests\BaseQueryBuilderTest;
// --------------------------------------------------------------------------
/** /**
* Class for testing Query Builder with SQLite * Class for testing Query Builder with SQLite
* *
@ -32,8 +30,6 @@ use Query\Tests\BaseQueryBuilderTest;
self::$db = Query('test_sqlite'); self::$db = Query('test_sqlite');
} }
// --------------------------------------------------------------------------
public function testQueryFunctionAlias() public function testQueryFunctionAlias()
{ {
$db = Query('test_sqlite'); $db = Query('test_sqlite');
@ -41,8 +37,6 @@ use Query\Tests\BaseQueryBuilderTest;
$this->assertTrue(self::$db === $db, "Alias passed into query function gives the original object back"); $this->assertTrue(self::$db === $db, "Alias passed into query function gives the original object back");
} }
// --------------------------------------------------------------------------
public function testQueryExplain() public function testQueryExplain()
{ {
$query = self::$db->select('id, key as k, val') $query = self::$db->select('id, key as k, val')

View File

@ -18,8 +18,6 @@ define('QTEST_DIR', realpath(__DIR__));
define('QBASE_DIR', realpath(QTEST_DIR.'/../') . '/'); define('QBASE_DIR', realpath(QTEST_DIR.'/../') . '/');
define('QDS', DIRECTORY_SEPARATOR); define('QDS', DIRECTORY_SEPARATOR);
// --------------------------------------------------------------------------
function get_json_config() function get_json_config()
{ {
$files = array( $files = array(
@ -38,7 +36,6 @@ function get_json_config()
return FALSE; return FALSE;
} }
// --------------------------------------------------------------------------
$path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db'; $path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db';
@unlink($path); @unlink($path);