Query/tests/CoreTest.php

62 lines
1.2 KiB
PHP
Raw Normal View History

2016-10-12 22:12:25 -04:00
<?php declare(strict_types=1);
/**
2016-10-12 22:12:25 -04:00
* Query
*
2016-10-12 22:12:25 -04:00
* SQL Query Builder / Database Abstraction Layer
*
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
2022-09-29 11:33:08 -04:00
* @version 4.0.0
*/
2023-03-17 15:30:36 -04:00
namespace Query\Tests;
2023-03-17 15:30:36 -04:00
use PDO;
2018-01-26 08:39:30 -05:00
use function Query;
use function regexInArray;
/**
* CoreTest class - Compatibility and core functionality tests
2014-02-19 13:45:05 -05:00
*
* @extends UnitTestCase
*/
2023-03-17 15:30:36 -04:00
class CoreTest extends TestCase
{
/**
* TestHasPDO function.
*/
public function testHasPDO(): void
{
// PDO class exists
$this->assertTrue(class_exists('PDO'));
2014-02-19 13:45:05 -05:00
// Make sure at least one of the supported drivers is enabled
$supported = [
'mysql',
'pgsql',
'sqlite',
];
2014-02-19 13:45:05 -05:00
2018-01-26 08:39:30 -05:00
$drivers = PDO::getAvailableDrivers();
2014-02-19 13:45:05 -05:00
2016-10-13 21:55:23 -04:00
$numSupported = count(array_intersect($drivers, $supported));
2014-02-19 13:45:05 -05:00
2016-10-13 21:55:23 -04:00
$this->assertTrue($numSupported > 0);
}
2018-01-24 13:14:03 -05:00
public function testNullQuery(): void
{
2018-01-26 08:39:30 -05:00
$this->assertNull(Query(NULL));
2018-01-24 13:14:03 -05:00
}
public function testEmptyRegexInArray(): void
{
2018-01-26 08:39:30 -05:00
$this->assertFalse(regexInArray([], 'foo'));
2018-01-24 13:14:03 -05:00
}
2023-03-17 15:30:36 -04:00
}