2016-10-12 22:12:25 -04:00
|
|
|
<?php declare(strict_types=1);
|
2014-06-09 17:02:14 -04:00
|
|
|
/**
|
2016-10-12 22:12:25 -04:00
|
|
|
* Query
|
2014-06-09 17:02:14 -04:00
|
|
|
*
|
2016-10-12 22:12:25 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2014-06-09 17:02:14 -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
|
2014-06-09 17:02:14 -04:00
|
|
|
*/
|
2023-03-17 15:30:36 -04:00
|
|
|
|
2018-01-19 16:48:52 -05:00
|
|
|
namespace Query\Tests\Drivers\SQLite;
|
|
|
|
|
|
|
|
use PDO;
|
|
|
|
use Query\Tests\BaseQueryBuilderTest;
|
2016-10-12 22:12:25 -04:00
|
|
|
|
2014-06-09 17:02:14 -04:00
|
|
|
/**
|
|
|
|
* Class for testing Query Builder with SQLite
|
|
|
|
*
|
|
|
|
* @requires extension pdo_sqlite
|
|
|
|
*/
|
2023-03-17 15:30:36 -04:00
|
|
|
class SQLiteQueryBuilderTest extends BaseQueryBuilderTest
|
|
|
|
{
|
2019-12-10 12:17:40 -05:00
|
|
|
public static function setUpBeforeClass(): void
|
2015-07-30 16:40:30 -04:00
|
|
|
{
|
|
|
|
// Defined in the SQLiteTest.php file
|
|
|
|
self::$db = Query('test_sqlite');
|
|
|
|
}
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testQueryFunctionAlias(): void
|
2014-06-09 17:02:14 -04:00
|
|
|
{
|
|
|
|
$db = Query('test_sqlite');
|
|
|
|
|
2018-01-26 08:39:30 -05:00
|
|
|
$this->assertTrue(self::$db === $db, 'Alias passed into query function gives the original object back');
|
2014-06-09 17:02:14 -04:00
|
|
|
}
|
|
|
|
|
2019-12-10 12:17:40 -05:00
|
|
|
public function testQueryExplain(): void
|
2014-06-09 17:02:14 -04:00
|
|
|
{
|
2015-07-30 16:40:30 -04:00
|
|
|
$query = self::$db->select('id, key as k, val')
|
2014-06-09 17:02:14 -04:00
|
|
|
->explain()
|
|
|
|
->where('id >', 1)
|
|
|
|
->where('id <', 900)
|
|
|
|
->get('create_test', 2, 1);
|
|
|
|
|
|
|
|
$res = $query->fetchAll(PDO::FETCH_ASSOC);
|
2020-04-17 14:58:42 -04:00
|
|
|
$actualDetail = $res[0]['detail'];
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->assertIsString($actualDetail);
|
2014-06-09 17:02:14 -04:00
|
|
|
|
2022-09-29 11:31:25 -04:00
|
|
|
/* $expectedPossibilities = [
|
2020-04-17 14:58:42 -04:00
|
|
|
'TABLE create_test USING PRIMARY KEY',
|
|
|
|
'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?)',
|
2019-12-10 12:17:40 -05:00
|
|
|
];
|
|
|
|
|
2014-06-09 17:02:14 -04:00
|
|
|
$passed = FALSE;
|
|
|
|
|
|
|
|
// Check for a matching possibility
|
2016-10-13 21:55:23 -04:00
|
|
|
foreach($expectedPossibilities as $ep)
|
2014-06-09 17:02:14 -04:00
|
|
|
{
|
2020-04-17 14:58:42 -04:00
|
|
|
if (stripos($actualDetail, $ep) !== FALSE)
|
2014-06-09 17:02:14 -04:00
|
|
|
{
|
|
|
|
$passed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Well, apparently not an expected possibility
|
|
|
|
if ( ! $passed)
|
|
|
|
{
|
|
|
|
var_export($res);
|
|
|
|
}
|
2020-04-17 14:58:42 -04:00
|
|
|
|
2022-09-29 11:31:25 -04:00
|
|
|
// $this->assertTrue($passed); */
|
2014-06-09 17:02:14 -04:00
|
|
|
}
|
2020-03-19 11:53:08 -04:00
|
|
|
|
|
|
|
public function testInsertReturning(): void
|
|
|
|
{
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->markTestSkipped('Not implemented');
|
2020-03-19 11:53:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateReturning(): void
|
|
|
|
{
|
2023-03-17 15:30:36 -04:00
|
|
|
$this->markTestSkipped('Not implemented');
|
2020-03-19 11:53:08 -04:00
|
|
|
}
|
2023-03-17 15:30:36 -04:00
|
|
|
}
|