Compare commits

...

11 Commits

6 changed files with 59 additions and 48 deletions

View File

@ -1,7 +1,10 @@
dist: xenial dist: bionic
os: linux os: linux
arch: amd64 arch:
- amd64
- arm64
- ppc64le
language: php language: php
@ -10,8 +13,10 @@ services:
- postgresql - postgresql
php: php:
- 7.4
- nightly - nightly
- '7.4'
# - '8.0'
before_script: before_script:
- psql -c 'DROP DATABASE IF EXISTS test;' -U postgres - psql -c 'DROP DATABASE IF EXISTS test;' -U postgres
@ -31,4 +36,5 @@ after_script:
jobs: jobs:
allow_failures: allow_failures:
- arch: ppc64le
- php: nightly - php: nightly

View File

@ -1,36 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" beStrictAboutOutputDuringTests="false" colors="true" stopOnFailure="false" bootstrap="./../tests/bootstrap.php" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
beStrictAboutOutputDuringTests="false" <coverage>
colors="true" <include>
stopOnFailure="false" <directory suffix=".php">./../src/</directory>
bootstrap="./../tests/bootstrap.php" </include>
verbose="true" <report>
> <clover outputFile="logs/clover.xml"/>
<filter> <html outputDirectory="./../coverage"/>
<whitelist> <xml outputDirectory="logs/coverage"/>
<directory suffix=".php">./../src/</directory> </report>
</whitelist> </coverage>
</filter> <testsuites>
<testsuites> <testsuite name="CoreTests">
<testsuite name="CoreTests"> <file>./../tests/CoreTest.php</file>
<file>./../tests/CoreTest.php</file> <file>./../tests/ConnectionManagerTest.php</file>
<file>./../tests/ConnectionManagerTest.php</file> <file>./../tests/QueryParserTest.php</file>
<file>./../tests/QueryParserTest.php</file> </testsuite>
</testsuite> <testsuite name="MySQL Tests">
<testsuite name="MySQL Tests"> <directory>./../tests/Drivers/MySQL/</directory>
<directory>./../tests/Drivers/MySQL/</directory> </testsuite>
</testsuite> <testsuite name="PgSQL Tests">
<testsuite name="PgSQL Tests"> <directory>./../tests/Drivers/PgSQL/</directory>
<directory>./../tests/Drivers/PgSQL/</directory> </testsuite>
</testsuite> <testsuite name="SQLite Tests">
<testsuite name="SQLite Tests"> <directory>./../tests/Drivers/SQLite/</directory>
<directory>./../tests/Drivers/SQLite/</directory> </testsuite>
</testsuite> </testsuites>
</testsuites> <logging>
<logging> <junit outputFile="logs/junit.xml"/>
<log type="coverage-html" target="./../coverage"/> </logging>
<log type="coverage-clover" target="logs/clover.xml"/> </phpunit>
<log type="coverage-xml" lowUpperBound="85" highLowerBound="90" showUncoveredFiles="true" target="logs/coverage" />
<log type="junit" target="logs/junit.xml" />
</logging>
</phpunit>

View File

@ -34,14 +34,13 @@
"require-dev": { "require-dev": {
"consolidation/robo": "^2.0.0", "consolidation/robo": "^2.0.0",
"monolog/monolog": "^2.0.1", "monolog/monolog": "^2.0.1",
"phploc/phploc": "^5.0", "phploc/phploc": "^7.0",
"phpmd/phpmd": "^2.8", "phpmd/phpmd": "^2.8",
"phpstan/phpstan": "^0.12.2", "phpstan/phpstan": "^0.12.2",
"phpunit/phpunit": "^8.5", "phpunit/phpunit": "^9.4",
"sebastian/phpcpd": "^4.1", "sebastian/phpcpd": "^6.0",
"simpletest/simpletest": "^1.1", "simpletest/simpletest": "^1.1",
"squizlabs/php_codesniffer": "^3.0.0", "squizlabs/php_codesniffer": "^3.0.0"
"theseer/phpdox": "^0.12.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -59,9 +59,8 @@ final class ConnectionManager {
* Prevent serialization of this object * Prevent serialization of this object
* *
* @throws DomainException * @throws DomainException
* @return void
*/ */
public function __sleep(): void public function __sleep()
{ {
throw new DomainException('No serializing of singleton'); throw new DomainException('No serializing of singleton');
} }

View File

@ -91,8 +91,6 @@ class ConnectionManagerTest extends TestCase {
}; };
$conn = self::$instance->connect($params); $conn = self::$instance->connect($params);
$this->assertInstanceOf(QueryBuilderInterface::class, $conn);
// Check that the connection just made is returned from the get_connection method // Check that the connection just made is returned from the get_connection method
$this->assertEqual($conn, self::$instance->getConnection()); $this->assertEqual($conn, self::$instance->getConnection());
@ -111,7 +109,6 @@ class ConnectionManagerTest extends TestCase {
]; ];
$conn = self::$instance->connect($params); $conn = self::$instance->connect($params);
$this->assertInstanceOf(QueryBuilderInterface::class, $conn);
$this->assertEqual($conn, self::$instance->getConnection('conn_manager')); $this->assertEqual($conn, self::$instance->getConnection('conn_manager'));
} }

View File

@ -154,6 +154,13 @@ SQL;
public function testCommitTransaction(): void public function testCommitTransaction(): void
{ {
// Make sure we aren't already in a transaction
if (self::$db->inTransaction())
{
self::$db->commit();
}
$this->assertFalse(self::$db->inTransaction());
$this->assertTrue(self::$db->beginTransaction()); $this->assertTrue(self::$db->beginTransaction());
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)';
@ -165,6 +172,13 @@ SQL;
public function testRollbackTransaction(): void public function testRollbackTransaction(): void
{ {
// Make sure we aren't already in a transaction
if (self::$db->inTransaction())
{
self::$db->commit();
}
$this->assertFalse(self::$db->inTransaction());
$this->assertTrue(self::$db->beginTransaction()); $this->assertTrue(self::$db->beginTransaction());
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)'; $sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)';