2016-10-12 22:12:25 -04:00
|
|
|
<?php declare(strict_types=1);
|
2012-04-13 16:50:05 -04:00
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
2016-10-12 22:12:25 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2012-04-13 16:50:05 -04:00
|
|
|
*
|
2022-09-29 11:33:08 -04:00
|
|
|
* PHP version 8.1
|
2016-10-12 22:12:25 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
2023-01-20 11:30:51 -05:00
|
|
|
* @author Timothy J. Warren <tim@timshome.page>
|
|
|
|
* @copyright 2012 - 2023 Timothy J. Warren
|
2016-10-12 22:12:25 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2019-12-11 16:49:42 -05:00
|
|
|
* @link https://git.timshomepage.net/aviat/Query
|
2023-03-17 16:34:21 -04:00
|
|
|
* @version 4.1.0
|
2012-04-13 16:50:05 -04:00
|
|
|
*/
|
2023-03-17 15:30:36 -04:00
|
|
|
|
2018-01-24 15:03:41 -05:00
|
|
|
namespace Query\Tests;
|
2012-04-13 16:50:05 -04:00
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
use Query\QueryBuilderInterface;
|
|
|
|
|
2012-04-13 16:50:05 -04:00
|
|
|
/**
|
|
|
|
* Parent Database Test Class
|
|
|
|
*/
|
2023-03-17 16:00:56 -04:00
|
|
|
abstract class BaseDriverTest extends BaseTestCase
|
2023-03-17 15:30:36 -04:00
|
|
|
{
|
2018-01-19 16:48:52 -05:00
|
|
|
/**
|
2019-12-10 12:17:40 -05:00
|
|
|
* @var QueryBuilderInterface|null
|
2018-01-19 16:48:52 -05:00
|
|
|
*/
|
|
|
|
protected static $db;
|
2015-07-17 15:38:06 -04:00
|
|
|
|
2014-02-14 22:08:19 -05:00
|
|
|
abstract public function testConnection();
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public static function tearDownAfterClass(): void
|
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
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetTables(): void
|
2012-04-13 16:50:05 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$tables = self::$db->getTables();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($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
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetSystemTables(): void
|
2012-04-13 16:50:05 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$tables = self::$db->getSystemTables();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($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
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testBackupData(): void
|
2012-04-18 16:28:12 -04:00
|
|
|
{
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsString(self::$db->getUtil()->backupData(['create_delete', FALSE]));
|
|
|
|
$this->assertIsString(self::$db->getUtil()->backupData(['create_delete', TRUE]));
|
2012-04-18 16:28:12 -04:00
|
|
|
}
|
2014-02-25 13:47:35 -05:00
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetColumns(): void
|
2012-05-09 13:54:38 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$cols = self::$db->getColumns('test');
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($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
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetTypes(): void
|
2012-05-09 13:54:38 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$types = self::$db->getTypes();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($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
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetFKs(): void
|
2014-04-07 16:49:49 -04:00
|
|
|
{
|
2018-01-26 08:39:30 -05:00
|
|
|
$expected = [[
|
2014-04-15 16:15:08 -04:00
|
|
|
'child_column' => 'ext_id',
|
|
|
|
'parent_table' => 'testconstraints',
|
2014-04-17 16:41:12 -04:00
|
|
|
'parent_column' => 'someid',
|
|
|
|
'update' => 'CASCADE',
|
2023-03-17 15:30:36 -04:00
|
|
|
'delete' => 'CASCADE',
|
2018-01-26 08:39:30 -05:00
|
|
|
]];
|
2014-04-15 16:15:08 -04:00
|
|
|
|
2016-10-13 21:55:23 -04:00
|
|
|
$keys = self::$db->getFks('testconstraints2');
|
2023-03-17 16:00:56 -04:00
|
|
|
$this->assertEquals($expected, $keys);
|
2014-04-07 16:49:49 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetIndexes(): void
|
2014-04-08 14:26:28 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$keys = self::$db->getIndexes('test');
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($keys);
|
2014-04-08 14:26:28 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetViews(): void
|
2014-04-23 15:53:16 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$views = self::$db->getViews();
|
2019-12-11 16:48:43 -05:00
|
|
|
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($views);
|
|
|
|
|
2019-12-11 16:48:43 -05:00
|
|
|
foreach (['numbersview', 'testview'] as $searchView)
|
|
|
|
{
|
|
|
|
$this->assertTrue(in_array($searchView, $views, TRUE));
|
|
|
|
}
|
2014-04-23 15:53:16 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetTriggers(): void
|
2014-04-28 16:41:46 -04:00
|
|
|
{
|
2023-01-20 10:33:43 -05:00
|
|
|
$this->markTestSkipped('Deprecated');
|
2014-04-28 16:41:46 -04:00
|
|
|
|
2016-10-13 21:55:23 -04:00
|
|
|
$triggers = self::$db->getTriggers();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($triggers);
|
2014-04-28 16:41:46 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetSequences(): void
|
2014-04-28 16:41:46 -04:00
|
|
|
{
|
2016-10-13 21:55:23 -04:00
|
|
|
$seqs = self::$db->getSequences();
|
2014-04-28 16:41:46 -04:00
|
|
|
|
|
|
|
// Normalize sequence names
|
|
|
|
$seqs = array_map('strtolower', $seqs);
|
|
|
|
|
2018-01-26 08:39:30 -05:00
|
|
|
$expected = ['newtable_seq'];
|
2014-04-28 16:41:46 -04:00
|
|
|
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($seqs);
|
2023-03-17 16:00:56 -04:00
|
|
|
$this->assertEquals($expected, $seqs);
|
2014-04-28 16:41:46 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetProcedures(): void
|
2014-04-28 16:41:46 -04:00
|
|
|
{
|
2023-01-20 10:33:43 -05:00
|
|
|
$this->markTestSkipped('Deprecated');
|
|
|
|
|
2016-10-13 21:55:23 -04:00
|
|
|
$procedures = self::$db->getProcedures();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($procedures);
|
2014-04-28 16:41:46 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testGetFunctions(): void
|
2014-04-28 16:41:46 -04:00
|
|
|
{
|
2023-01-20 10:33:43 -05:00
|
|
|
$this->markTestSkipped('Deprecated');
|
|
|
|
|
2016-10-13 21:55:23 -04:00
|
|
|
$funcs = self::$db->getFunctions();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsArray($funcs);
|
2014-04-28 16:41:46 -04:00
|
|
|
}
|
2019-12-13 15:11:49 -05:00
|
|
|
|
|
|
|
public function testGetVersion(): void
|
|
|
|
{
|
|
|
|
$version = self::$db->getVersion();
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsString($version);
|
|
|
|
$this->assertTrue($version !== '');
|
2019-12-13 15:11:49 -05:00
|
|
|
}
|
2012-04-13 16:50:05 -04:00
|
|
|
}
|
2023-03-17 15:30:36 -04:00
|
|
|
// End of db_test.php
|