Improve some tests and docblocks
This commit is contained in:
parent
315dc5e1c5
commit
6a38213a62
@ -43,13 +43,13 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
||||
|
||||
/**
|
||||
* Reference to sql class
|
||||
* @var SQL_Interface
|
||||
* @var SQL\SQL_Interface
|
||||
*/
|
||||
public $sql;
|
||||
|
||||
/**
|
||||
* Reference to util class
|
||||
* @var Abstract_Util
|
||||
* @var Util\Abstract_Util
|
||||
*/
|
||||
public $util;
|
||||
|
||||
@ -340,7 +340,9 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
||||
*/
|
||||
public function get_tables()
|
||||
{
|
||||
return $this->driver_query('table_list');
|
||||
$tables = $this->driver_query('table_list');
|
||||
natsort($tables);
|
||||
return $tables;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -364,7 +366,9 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
||||
*/
|
||||
public function get_views()
|
||||
{
|
||||
return $this->driver_query('view_list');
|
||||
$views = $this->driver_query('view_list');
|
||||
sort($views);
|
||||
return $views;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -583,10 +587,9 @@ abstract class Abstract_Driver extends \PDO implements Driver_Interface {
|
||||
// and is not already quoted before quoting
|
||||
// that value, otherwise, return the original value
|
||||
return (
|
||||
strpos($str, $this->escape_char) !== 0
|
||||
is_string($str)
|
||||
&& strpos($str, $this->escape_char) !== 0
|
||||
&& strrpos($str, $this->escape_char) !== 0
|
||||
&& is_string($str)
|
||||
&& ! is_numeric($str)
|
||||
)
|
||||
? "{$this->escape_char}{$str}{$this->escape_char}"
|
||||
: $str;
|
||||
|
@ -347,7 +347,7 @@ abstract class Abstract_Query_Builder implements Query_Builder_Interface {
|
||||
{
|
||||
$where = array();
|
||||
$this->_mixed_set($where, $key, $val, self::BOTH);
|
||||
$this->where_values = $this->_mixed_set($this->where_values, $key, $val, self::VALUE);
|
||||
$this->_mixed_set($this->where_values, $key, $val, self::VALUE);
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
@ -478,8 +478,8 @@ class Query_Builder extends Abstract_Query_Builder {
|
||||
*/
|
||||
public function set($key, $val = NULL)
|
||||
{
|
||||
$this->set_array_keys = $this->_mixed_set($this->set_array_keys, $key, $val, self::KEY);
|
||||
$this->values = $this->_mixed_set($this->values, $key, $val, self::VALUE);
|
||||
$this->_mixed_set($this->set_array_keys, $key, $val, self::KEY);
|
||||
$this->_mixed_set($this->values, $key, $val, self::VALUE);
|
||||
|
||||
// Use the keys of the array to make the insert/update string
|
||||
// Escape the field names
|
||||
|
@ -131,7 +131,7 @@ SQL;
|
||||
public function view_list()
|
||||
{
|
||||
return <<<SQL
|
||||
SELECT DISTINCT "RDB\$VIEW_NAME"
|
||||
SELECT DISTINCT TRIM("RDB\$VIEW_NAME")
|
||||
FROM "RDB\$VIEW_RELATIONS"
|
||||
SQL;
|
||||
}
|
||||
@ -201,7 +201,7 @@ SQL;
|
||||
public function sequence_list()
|
||||
{
|
||||
return <<<SQL
|
||||
SELECT "RDB\$GENERATOR_NAME"
|
||||
SELECT TRIM("RDB\$GENERATOR_NAME")
|
||||
FROM "RDB\$GENERATORS"
|
||||
WHERE "RDB\$SYSTEM_FLAG" = 0
|
||||
SQL;
|
||||
|
@ -62,7 +62,6 @@ class SQLite extends Abstract_Driver {
|
||||
public function get_tables()
|
||||
{
|
||||
$sql = $this->sql->table_list();
|
||||
|
||||
$res = $this->query($sql);
|
||||
return db_filter($res->fetchAll(\PDO::FETCH_ASSOC), 'name');
|
||||
}
|
||||
|
@ -98,8 +98,51 @@ abstract class DBTest extends Query_TestCase {
|
||||
|
||||
public function testGetViews()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_views()));
|
||||
$views = $this->db->get_views();
|
||||
$expected = array('numbersview', 'testview');
|
||||
$this->assertEqual($expected, array_values($views));
|
||||
$this->assertTrue(is_array($views));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetTriggers()
|
||||
{
|
||||
// @TODO standardize trigger output for different databases
|
||||
|
||||
$triggers = $this->db->get_triggers();
|
||||
$this->assertTrue(is_array($triggers));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSequences()
|
||||
{
|
||||
$seqs = $this->db->get_sequences();
|
||||
|
||||
// Normalize sequence names
|
||||
$seqs = array_map('strtolower', $seqs);
|
||||
|
||||
$expected = array('newtable_seq');
|
||||
|
||||
$this->assertTrue(is_array($seqs));
|
||||
$this->assertEqual($expected, $seqs);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetProcedures()
|
||||
{
|
||||
$procedures = $this->db->get_procedures();
|
||||
$this->assertTrue(is_array($procedures));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$funcs = $this->db->get_functions();
|
||||
$this->assertTrue(is_array($funcs));
|
||||
}
|
||||
}
|
||||
// End of db_test.php
|
@ -219,34 +219,6 @@ SQL;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSequences()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_sequences()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetProcedures()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_procedures()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_functions()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetTriggers()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_triggers()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testErrorInfo()
|
||||
{
|
||||
$result = $this->db->errorInfo();
|
||||
|
@ -195,27 +195,6 @@ SQL;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetsProcedures()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_procedures()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_functions()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetTriggers()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_triggers()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSequences()
|
||||
{
|
||||
$this->assertNull($this->db->get_sequences());
|
||||
@ -227,4 +206,6 @@ SQL;
|
||||
{
|
||||
$this->assertTrue(is_string($this->db->util->backup_structure()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -222,27 +222,6 @@ SQL;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSequences()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_sequences()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetProcedures()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_procedures()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetTriggers()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_triggers()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetDBs()
|
||||
{
|
||||
$this->assertTrue(is_array($this->db->get_dbs()));
|
||||
|
@ -261,15 +261,32 @@ SQL;
|
||||
$this->assertEqual(NULL, $sql);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSystemTables()
|
||||
{
|
||||
$sql = $this->db->get_system_tables();
|
||||
$this->assertTrue(is_array($sql));
|
||||
}
|
||||
|
||||
public function testGetTriggers()
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetSequences()
|
||||
{
|
||||
$sql = $this->db->get_triggers();
|
||||
$this->assertTrue(is_array($sql));
|
||||
$this->assertNull($this->db->get_sequences());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetFunctions()
|
||||
{
|
||||
$this->assertNull($this->db->get_functions());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGetProcedures()
|
||||
{
|
||||
$this->assertNull($this->db->get_procedures());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user