attempt at getting MySQL tests working

This commit is contained in:
Joby Elliott 2018-09-14 12:17:54 -06:00
parent 03826b87d6
commit c9938955f9
10 changed files with 47 additions and 35 deletions

1
.gitignore vendored
View file

@ -3,4 +3,5 @@ composer.lock
.phpunit.result.cache
test.php
test.sqlite
*.test.sqlite
.DS_Store

View file

@ -1,4 +1,11 @@
image: php:7.1-alpine
image: php:7.1-alpine
services:
- mysql:latest
variables:
MYSQL_DATABASE: destructr_test
MYSQL_ROOT_PASSWORD: badpassword
before_script:
- apk update
@ -11,10 +18,10 @@ test:local:
script:
- php composer.phar test-local
# test:db:
# script:
# - docker-php-ext-install pdo_mysql
# - php composer.phar test-db
test:drivers:
script:
- docker-php-ext-install pdo_mysql
- php composer.phar test-mysql
test:sqlite:
script:

View file

@ -21,8 +21,8 @@
"test-local": [
"phpunit --testsuite Local"
],
"test-db": [
"phpunit --testsuite DB"
"test-mysql": [
"phpunit --testsuite MySQL"
],
"test-sqlite": [
"phpunit --testsuite SQLite"

View file

@ -5,8 +5,8 @@
<exclude>tests/Drivers</exclude>
<exclude>tests/LegacyDrivers</exclude>
</testsuite>
<testsuite name="Drivers">
<directory>tests/Drivers</directory>
<testsuite name="MySQL">
<directory>tests/Drivers/MySQL</directory>
</testsuite>
<testsuite name="SQLite">
<directory>tests/LegacyDrivers/SQLite</directory>

View file

@ -1,7 +1,7 @@
<?php
/* Destructr | https://gitlab.com/byjoby/destructr | MIT License */
declare(strict_types=1);
namespace Destructr\Drivers\IntegrationTests;
namespace Destructr\Drivers;
use PHPUnit\Framework\TestCase;
use PHPUnit\DbUnit\TestCaseTrait;

View file

@ -1,16 +0,0 @@
<?php
/* Destructr | https://gitlab.com/byjoby/destructr | MIT License */
declare(strict_types=1);
namespace Destructr\Drivers\IntegrationTests;
use PHPUnit\Framework\TestCase;
class MySQLDriverTest extends AbstractDriverIntegrationTest
{
const DRIVER_CLASS = \Destructr\Drivers\MySQLDriver::class;
const DRIVER_DSN = 'mysql:host=mysql;dbname=ci';
const DRIVER_USERNAME = 'ci_password';
const DRIVER_PASSWORD = null;
const DRIVER_OPTIONS = null;
const TEST_TABLE = 'mysqlintegrationtest';
}

View file

@ -0,0 +1,18 @@
<?php
/* Destructr | https://gitlab.com/byjoby/destructr | MIT License */
declare(strict_types=1);
namespace Destructr\Drivers\MySQL;
use PHPUnit\Framework\TestCase;
use Destructr\Drivers\AbstractDriverIntegrationTest;
use Destructr\Drivers\MySQLDriver;
class MySQLDriverIntegrationTest extends AbstractDriverIntegrationTest
{
const DRIVER_CLASS = \Destructr\Drivers\MySQLDriver::class;
const DRIVER_DSN = 'mysql:host=mysql;dbname=destructr_test';
const DRIVER_USERNAME = 'root';
const DRIVER_PASSWORD = 'badpassword';
const DRIVER_OPTIONS = null;
const TEST_TABLE = 'integrationtest';
}

View file

@ -1,15 +1,17 @@
<?php
/* Destructr | https://gitlab.com/byjoby/destructr | MIT License */
declare(strict_types=1);
namespace Destructr\Drivers;
namespace Destructr\Drivers\MySQL;
use PHPUnit\Framework\TestCase;
use Destructr\Drivers\AbstractDriverTest;
use Destructr\Drivers\MySQLDriver;
class MySQLDriverTest extends AbstractDriverTest
{
const DRIVER_CLASS = MySQLDriver::class;
const DRIVER_DSN = 'mysql:host=mysql;dbname=ci';
const DRIVER_USERNAME = 'ci_password';
const DRIVER_PASSWORD = null;
const DRIVER_DSN = 'mysql:host=mysql;dbname=destructr_test';
const DRIVER_USERNAME = 'root';
const DRIVER_PASSWORD = 'badpassword';
const DRIVER_OPTIONS = null;
}

View file

@ -4,13 +4,13 @@ declare(strict_types=1);
namespace Destructr\LegacyDrivers\SQLite;
use PHPUnit\Framework\TestCase;
use Destructr\Drivers\IntegrationTests\AbstractDriverIntegrationTest;
use Destructr\Drivers\AbstractDriverIntegrationTest;
use Destructr\LegacyDrivers\SQLiteDriver;
class MySQLDriverTest extends AbstractDriverIntegrationTest
{
const DRIVER_CLASS = SQLiteDriver::class;
const DRIVER_DSN = 'sqlite:'.__DIR__.'/test.sqlite';
const DRIVER_DSN = 'sqlite:'.__DIR__.'/integration.test.sqlite';
const DRIVER_USERNAME = null;
const DRIVER_PASSWORD = null;
const DRIVER_OPTIONS = null;
@ -18,6 +18,6 @@ class MySQLDriverTest extends AbstractDriverIntegrationTest
public static function setUpBeforeClass()
{
@unlink(__DIR__.'/test.sqlite');
@unlink(__DIR__.'/integration.test.sqlite');
}
}

View file

@ -10,13 +10,13 @@ use Destructr\LegacyDrivers\SQLiteDriver;
class SQLiteDriverTest extends AbstractDriverTest
{
const DRIVER_CLASS = SQLiteDriver::class;
const DRIVER_DSN = 'sqlite:'.__DIR__.'/test.sqlite';
const DRIVER_DSN = 'sqlite:'.__DIR__.'/driver.test.sqlite';
const DRIVER_USERNAME = null;
const DRIVER_PASSWORD = null;
const DRIVER_OPTIONS = null;
public static function setUpBeforeClass()
{
@unlink(__DIR__.'/test.sqlite');
@unlink(__DIR__.'/driver.test.sqlite');
}
}