2016-10-12 22:12:25 -04:00
|
|
|
<?php declare(strict_types=1);
|
2012-04-13 13:48:38 -04:00
|
|
|
/**
|
2016-10-12 22:12:25 -04:00
|
|
|
* Query
|
2012-04-13 13:48:38 -04:00
|
|
|
*
|
2016-10-12 22:12:25 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2012-04-13 13:48:38 -04:00
|
|
|
*
|
2019-12-11 16:49:42 -05:00
|
|
|
* PHP version 7.2
|
2016-10-12 22:12:25 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2020-03-18 13:53:22 -04:00
|
|
|
* @copyright 2012 - 2019 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
|
|
|
|
* @version 3.0.0
|
2012-04-13 13:48:38 -04:00
|
|
|
*/
|
2018-01-19 16:48:52 -05:00
|
|
|
namespace Query\Tests;
|
|
|
|
|
2018-01-26 08:39:30 -05:00
|
|
|
use function Query;
|
|
|
|
use function regexInArray;
|
|
|
|
use PDO;
|
|
|
|
|
2012-04-13 13:48:38 -04:00
|
|
|
/**
|
|
|
|
* CoreTest class - Compatibility and core functionality tests
|
2014-02-19 13:45:05 -05:00
|
|
|
*
|
2012-04-13 13:48:38 -04:00
|
|
|
* @extends UnitTestCase
|
|
|
|
*/
|
2018-01-19 16:48:52 -05:00
|
|
|
class CoreTest extends TestCase {
|
2012-04-13 13:48:38 -04:00
|
|
|
/**
|
|
|
|
* TestHasPDO function.
|
2014-02-19 13:45:05 -05:00
|
|
|
*
|
2012-04-13 13:48:38 -04:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-01-22 12:03:37 -05:00
|
|
|
public function testHasPDO(): void
|
2012-04-13 13:48:38 -04:00
|
|
|
{
|
|
|
|
// PDO class exists
|
|
|
|
$this->assertTrue(class_exists('PDO'));
|
2014-02-19 13:45:05 -05:00
|
|
|
|
|
|
|
|
2012-04-13 13:48:38 -04:00
|
|
|
// Make sure at least one of the supported drivers is enabled
|
2018-01-19 16:48:52 -05:00
|
|
|
$supported = [
|
2012-04-13 13:48:38 -04:00
|
|
|
'mysql',
|
|
|
|
'pgsql',
|
|
|
|
'sqlite',
|
2018-01-19 16:48:52 -05:00
|
|
|
];
|
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);
|
2012-04-13 13:48:38 -04:00
|
|
|
}
|
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
|
|
|
}
|
2012-04-13 13:48:38 -04:00
|
|
|
}
|