2012-04-13 16:50:05 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
2012-04-20 13:17:39 -04:00
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
2014-02-18 15:18:01 -05:00
|
|
|
* @copyright Copyright (c) 2012 - 2014
|
2012-04-13 16:50:05 -04:00
|
|
|
* @link https://github.com/aviat4ion/Query
|
2012-04-20 13:17:39 -04:00
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
2012-04-13 16:50:05 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parent Database Test Class
|
|
|
|
*/
|
2014-02-14 22:08:19 -05:00
|
|
|
abstract class DBTest extends Query_TestCase {
|
2012-04-13 16:50:05 -04:00
|
|
|
|
2015-07-17 15:38:06 -04:00
|
|
|
protected static $db = NULL;
|
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
abstract public function testConnection();
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-04-13 16:50:05 -04:00
|
|
|
|
2015-07-17 15:38:06 -04:00
|
|
|
public static function tearDownAfterClass()
|
2012-04-13 16:50:05 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
self::$db = NULL;
|
2012-04-13 16:50:05 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-04-13 16:50:05 -04:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
public function testGetTables()
|
2012-04-13 16:50:05 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$tables = self::$db->get_tables();
|
2012-04-13 16:50:05 -04:00
|
|
|
$this->assertTrue(is_array($tables));
|
2014-04-08 17:13:41 -04:00
|
|
|
$this->assertTrue( ! empty($tables));
|
2012-04-13 16:50:05 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-04-13 16:50:05 -04:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
public function testGetSystemTables()
|
2012-04-13 16:50:05 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$tables = self::$db->get_system_tables();
|
2012-04-13 16:50:05 -04:00
|
|
|
$this->assertTrue(is_array($tables));
|
2014-04-08 17:13:41 -04:00
|
|
|
$this->assertTrue( ! empty($tables));
|
2012-04-13 16:50:05 -04:00
|
|
|
}
|
2014-04-08 17:13:41 -04:00
|
|
|
|
2012-04-24 14:00:44 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
public function testBackupData()
|
2012-04-18 16:28:12 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$this->assertTrue(is_string(self::$db->util->backup_data(array('create_delete', TRUE))));
|
2012-04-18 16:28:12 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2012-05-09 13:54:38 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
public function testGetColumns()
|
2012-05-09 13:54:38 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$cols = self::$db->get_columns('test');
|
2012-05-09 13:54:38 -04:00
|
|
|
$this->assertTrue(is_array($cols));
|
2014-04-08 17:13:41 -04:00
|
|
|
$this->assertTrue( ! empty($cols));
|
2012-05-09 13:54:38 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2012-05-09 13:54:38 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
public function testGetTypes()
|
2012-05-09 13:54:38 -04:00
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$types = self::$db->get_types();
|
2012-05-09 13:54:38 -04:00
|
|
|
$this->assertTrue(is_array($types));
|
2014-04-08 17:13:41 -04:00
|
|
|
$this->assertTrue( ! empty($types));
|
2012-05-09 13:54:38 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2014-04-07 16:49:49 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetFKs()
|
|
|
|
{
|
2014-04-15 16:15:08 -04:00
|
|
|
$expected = array(array(
|
|
|
|
'child_column' => 'ext_id',
|
|
|
|
'parent_table' => 'testconstraints',
|
2014-04-17 16:41:12 -04:00
|
|
|
'parent_column' => 'someid',
|
|
|
|
'update' => 'CASCADE',
|
|
|
|
'delete' => 'CASCADE'
|
2014-04-15 16:15:08 -04:00
|
|
|
));
|
|
|
|
|
2015-07-17 15:38:06 -04:00
|
|
|
$keys = self::$db->get_fks('testconstraints2');
|
2014-04-15 16:15:08 -04:00
|
|
|
$this->assertEqual($expected, $keys);
|
2014-04-07 16:49:49 -04:00
|
|
|
}
|
|
|
|
|
2014-04-08 14:26:28 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetIndexes()
|
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$keys = self::$db->get_indexes('test');
|
2014-04-08 14:26:28 -04:00
|
|
|
$this->assertTrue(is_array($keys));
|
|
|
|
}
|
|
|
|
|
2014-04-23 15:53:16 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetViews()
|
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$views = self::$db->get_views();
|
2014-04-28 16:41:46 -04:00
|
|
|
$expected = array('numbersview', 'testview');
|
|
|
|
$this->assertEqual($expected, array_values($views));
|
|
|
|
$this->assertTrue(is_array($views));
|
2014-04-23 15:53:16 -04:00
|
|
|
}
|
|
|
|
|
2014-04-28 16:41:46 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetTriggers()
|
|
|
|
{
|
|
|
|
// @TODO standardize trigger output for different databases
|
|
|
|
|
2015-07-17 15:38:06 -04:00
|
|
|
$triggers = self::$db->get_triggers();
|
2014-04-28 16:41:46 -04:00
|
|
|
$this->assertTrue(is_array($triggers));
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetSequences()
|
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$seqs = self::$db->get_sequences();
|
2014-04-28 16:41:46 -04:00
|
|
|
|
|
|
|
// Normalize sequence names
|
|
|
|
$seqs = array_map('strtolower', $seqs);
|
|
|
|
|
|
|
|
$expected = array('newtable_seq');
|
|
|
|
|
|
|
|
$this->assertTrue(is_array($seqs));
|
|
|
|
$this->assertEqual($expected, $seqs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetProcedures()
|
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$procedures = self::$db->get_procedures();
|
2014-04-28 16:41:46 -04:00
|
|
|
$this->assertTrue(is_array($procedures));
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
public function testGetFunctions()
|
|
|
|
{
|
2015-07-17 15:38:06 -04:00
|
|
|
$funcs = self::$db->get_functions();
|
2014-04-28 16:41:46 -04:00
|
|
|
$this->assertTrue(is_array($funcs));
|
|
|
|
}
|
2012-04-13 16:50:05 -04:00
|
|
|
}
|
|
|
|
// End of db_test.php
|