Test overhaul (#2)
* first attempt at PHPUnit tests in github actions * composer ignore platform deps * another try * plumbing * pdo auth * more plumbing * doing env variables right * will this work? * calling phpunit directly * don't specify test * export * bug fix * trying something * trying another thing * trying again * trying it right * might work this time * testing can't work on 7.0
This commit is contained in:
parent
2f94e2f7eb
commit
f9a95898d4
16 changed files with 346 additions and 115 deletions
46
.github/workflows/test.yml
vendored
Normal file
46
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
name: Test suite
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
phpunit:
|
||||||
|
name: PHPUnit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php: ["7.1", "7.2", "7.3", "7.4"]
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: destructr_test
|
||||||
|
ports:
|
||||||
|
- 3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:10.2
|
||||||
|
env:
|
||||||
|
MARIADB_ROOT_PASSWORD: root
|
||||||
|
MARIADB_DATABASE: destructr_test
|
||||||
|
ports:
|
||||||
|
- 3306
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Composer install
|
||||||
|
run: composer install -o --no-progress --ignore-platform-reqs
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql
|
||||||
|
coverage: none
|
||||||
|
ini-values: variables_order=EGPCS
|
||||||
|
- name: PHPUnit
|
||||||
|
env:
|
||||||
|
TEST_MYSQL_SERVER: 127.0.0.1
|
||||||
|
TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
TEST_MARIADB_SERVER: 127.0.0.1
|
||||||
|
TEST_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
|
||||||
|
run: ./vendor/bin/phpunit
|
|
@ -1,28 +0,0 @@
|
||||||
image: php:7.1-alpine
|
|
||||||
|
|
||||||
services:
|
|
||||||
- mysql:5.7
|
|
||||||
|
|
||||||
variables:
|
|
||||||
MYSQL_DATABASE: destructr_test
|
|
||||||
MYSQL_ROOT_PASSWORD: badpassword
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- apk update
|
|
||||||
- apk add git
|
|
||||||
- docker-php-ext-install pdo
|
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
|
||||||
- php composer.phar install
|
|
||||||
|
|
||||||
test:local:
|
|
||||||
script:
|
|
||||||
- php composer.phar test-local
|
|
||||||
|
|
||||||
test:mysql:
|
|
||||||
script:
|
|
||||||
- docker-php-ext-install pdo_mysql
|
|
||||||
- php composer.phar test-mysql
|
|
||||||
|
|
||||||
test:sqlite:
|
|
||||||
script:
|
|
||||||
- php composer.phar test-sqlite
|
|
13
.travis.yml
13
.travis.yml
|
@ -1,13 +0,0 @@
|
||||||
language: php
|
|
||||||
services:
|
|
||||||
- mysql
|
|
||||||
php:
|
|
||||||
- 7.3
|
|
||||||
- 7.4
|
|
||||||
before_install:
|
|
||||||
- mysql -e 'CREATE DATABASE test'
|
|
||||||
- docker run -d -p 127.0.0.1:3307:3306 --name mysqld -e MYSQL_DATABASE=destructrtest -e MYSQL_USER=destructrtest -e MYSQL_PASSWORD=destructrtest -e MYSQL_ROOT_PASSWORD=verysecret mariadb:10.2 --innodb_log_file_size=256MB --innodb_buffer_pool_size=512MB --max_allowed_packet=16MB
|
|
||||||
- sleep 15
|
|
||||||
install:
|
|
||||||
- composer install
|
|
||||||
script: composer test
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Destructr
|
# Destructr
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/jobyone/destructr.svg?branch=main)](https://travis-ci.org/jobyone/destructr)
|
[![PHPUnit Tests](https://github.com/jobyone/destructr/actions/workflows/test.yml/badge.svg)](https://github.com/jobyone/destructr/actions/workflows/test.yml)
|
||||||
|
|
||||||
Destructr is a specialized ORM that allows a seamless mix of structured, relational data with unstructured JSON data.
|
Destructr is a specialized ORM that allows a seamless mix of structured, relational data with unstructured JSON data.
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,21 @@ abstract class AbstractSQLDriverIntegrationTest extends TestCase
|
||||||
use TestCaseTrait;
|
use TestCaseTrait;
|
||||||
const TEST_TABLE = 'integrationtest';
|
const TEST_TABLE = 'integrationtest';
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_OPTIONS()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
$pdo = static::createPDO();
|
$pdo = static::createPDO();
|
||||||
|
@ -138,10 +153,10 @@ abstract class AbstractSQLDriverIntegrationTest extends TestCase
|
||||||
{
|
{
|
||||||
$class = static::DRIVER_CLASS;
|
$class = static::DRIVER_CLASS;
|
||||||
return new $class(
|
return new $class(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,10 +172,10 @@ abstract class AbstractSQLDriverIntegrationTest extends TestCase
|
||||||
protected static function createPDO()
|
protected static function createPDO()
|
||||||
{
|
{
|
||||||
return new \PDO(
|
return new \PDO(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,21 @@ abstract class AbstractSQLDriverSchemaChangeTest extends TestCase
|
||||||
use TestCaseTrait;
|
use TestCaseTrait;
|
||||||
const TEST_TABLE = 'schematest';
|
const TEST_TABLE = 'schematest';
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_OPTIONS()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public function testSchemaChanges()
|
public function testSchemaChanges()
|
||||||
{
|
{
|
||||||
// set up using schema A
|
// set up using schema A
|
||||||
|
@ -103,20 +118,20 @@ abstract class AbstractSQLDriverSchemaChangeTest extends TestCase
|
||||||
{
|
{
|
||||||
$class = static::DRIVER_CLASS;
|
$class = static::DRIVER_CLASS;
|
||||||
return new $class(
|
return new $class(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function createPDO()
|
protected static function createPDO()
|
||||||
{
|
{
|
||||||
return new \PDO(
|
return new \PDO(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers;
|
namespace Destructr\Drivers;
|
||||||
|
|
||||||
use Destructr\DSO;
|
use Destructr\DSO;
|
||||||
|
@ -21,6 +23,23 @@ abstract class AbstractSQLDriverTest extends TestCase
|
||||||
{
|
{
|
||||||
use TestCaseTrait;
|
use TestCaseTrait;
|
||||||
|
|
||||||
|
abstract protected static function DRIVER_DSN();
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_OPTIONS()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
In actual practice, these would come from a Factory
|
In actual practice, these would come from a Factory
|
||||||
*/
|
*/
|
||||||
|
@ -139,10 +158,10 @@ abstract class AbstractSQLDriverTest extends TestCase
|
||||||
{
|
{
|
||||||
$class = static::DRIVER_CLASS;
|
$class = static::DRIVER_CLASS;
|
||||||
return new $class(
|
return new $class(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,10 +177,10 @@ abstract class AbstractSQLDriverTest extends TestCase
|
||||||
protected static function createPDO()
|
protected static function createPDO()
|
||||||
{
|
{
|
||||||
return new \PDO(
|
return new \PDO(
|
||||||
static::DRIVER_DSN,
|
static::DRIVER_DSN(),
|
||||||
static::DRIVER_USERNAME,
|
static::DRIVER_USERNAME(),
|
||||||
static::DRIVER_PASSWORD,
|
static::DRIVER_PASSWORD(),
|
||||||
static::DRIVER_OPTIONS
|
static::DRIVER_OPTIONS()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MariaDB;
|
namespace Destructr\Drivers\MariaDB;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MariaDBDriver;
|
||||||
class MariaDBDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
class MariaDBDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MariaDBDriver::class;
|
const DRIVER_CLASS = MariaDBDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;port=3307;dbname=destructrtest';
|
|
||||||
const DRIVER_USERNAME = 'destructrtest';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = 'destructrtest';
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MariaDB;
|
namespace Destructr\Drivers\MariaDB;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MariaDBDriver;
|
||||||
class MariaDBDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
class MariaDBDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MariaDBDriver::class;
|
const DRIVER_CLASS = MariaDBDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;port=3307;dbname=destructrtest';
|
|
||||||
const DRIVER_USERNAME = 'destructrtest';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = 'destructrtest';
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MariaDB;
|
namespace Destructr\Drivers\MariaDB;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverTest;
|
use Destructr\Drivers\AbstractSQLDriverTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MariaDBDriver;
|
||||||
class MariaDBDriverTest extends AbstractSQLDriverTest
|
class MariaDBDriverTest extends AbstractSQLDriverTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MariaDBDriver::class;
|
const DRIVER_CLASS = MariaDBDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;port=3307;dbname=destructrtest';
|
|
||||||
const DRIVER_USERNAME = 'destructrtest';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = 'destructrtest';
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MARIADB_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MySQL;
|
namespace Destructr\Drivers\MySQL;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MySQLDriver;
|
||||||
class MySQLDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
class MySQLDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MySQLDriver::class;
|
const DRIVER_CLASS = MySQLDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;dbname=test';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = null;
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MySQL;
|
namespace Destructr\Drivers\MySQL;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MySQLDriver;
|
||||||
class MySQLDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
class MySQLDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MySQLDriver::class;
|
const DRIVER_CLASS = MySQLDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;dbname=test';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = null;
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\MySQL;
|
namespace Destructr\Drivers\MySQL;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverTest;
|
use Destructr\Drivers\AbstractSQLDriverTest;
|
||||||
|
@ -9,8 +11,29 @@ use Destructr\Drivers\MySQLDriver;
|
||||||
class MySQLDriverTest extends AbstractSQLDriverTest
|
class MySQLDriverTest extends AbstractSQLDriverTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = MySQLDriver::class;
|
const DRIVER_CLASS = MySQLDriver::class;
|
||||||
const DRIVER_DSN = 'mysql:host=127.0.0.1;dbname=test';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
protected static function DRIVER_DSN()
|
||||||
const DRIVER_PASSWORD = null;
|
{
|
||||||
const DRIVER_OPTIONS = null;
|
return sprintf(
|
||||||
|
'mysql:host=%s:%s;dbname=%s',
|
||||||
|
$_ENV['TEST_MYSQL_SERVER'],
|
||||||
|
$_ENV['TEST_MYSQL_PORT'],
|
||||||
|
static::DRIVER_DBNAME()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_DBNAME'] ?? 'destructr_test';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_USER'] ?? 'root';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_PASSWORD()
|
||||||
|
{
|
||||||
|
return @$_ENV['TEST_MYSQL_PASSWORD'] ?? 'root';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\SQLite;
|
namespace Destructr\Drivers\SQLite;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
use Destructr\Drivers\AbstractSQLDriverIntegrationTest;
|
||||||
|
@ -9,13 +11,24 @@ use Destructr\Drivers\SQLiteDriver;
|
||||||
class SQLiteDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
class SQLiteDriverIntegrationTest extends AbstractSQLDriverIntegrationTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = SQLiteDriver::class;
|
const DRIVER_CLASS = SQLiteDriver::class;
|
||||||
const DRIVER_DSN = 'sqlite:'.__DIR__.'/integration.test.sqlite';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
|
||||||
const DRIVER_PASSWORD = '';
|
|
||||||
const DRIVER_OPTIONS = null;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
@unlink(__DIR__.'/integration.test.sqlite');
|
@unlink(__DIR__ . '/integration.test.sqlite');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function DRIVER_DSN()
|
||||||
|
{
|
||||||
|
return 'sqlite:' . __DIR__ . '/integration.test.sqlite';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\SQLite;
|
namespace Destructr\Drivers\SQLite;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
use Destructr\Drivers\AbstractSQLDriverSchemaChangeTest;
|
||||||
|
@ -9,13 +11,24 @@ use Destructr\Drivers\SQLiteDriver;
|
||||||
class SQLiteDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
class SQLiteDriverSchemaChangeTest extends AbstractSQLDriverSchemaChangeTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = SQLiteDriver::class;
|
const DRIVER_CLASS = SQLiteDriver::class;
|
||||||
const DRIVER_DSN = 'sqlite:'.__DIR__.'/schema.test.sqlite';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
|
||||||
const DRIVER_PASSWORD = '';
|
|
||||||
const DRIVER_OPTIONS = null;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
@unlink(__DIR__.'/schema.test.sqlite');
|
@unlink(__DIR__ . '/schema.test.sqlite');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function DRIVER_DSN()
|
||||||
|
{
|
||||||
|
return 'sqlite:' . __DIR__ . '/schema.test.sqlite';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
/* Destructr | https://github.com/jobyone/destructr | MIT License */
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Destructr\Drivers\SQLite;
|
namespace Destructr\Drivers\SQLite;
|
||||||
|
|
||||||
use Destructr\Drivers\AbstractSQLDriverTest;
|
use Destructr\Drivers\AbstractSQLDriverTest;
|
||||||
|
@ -9,13 +11,24 @@ use Destructr\Drivers\SQLiteDriver;
|
||||||
class SQLiteDriverTest extends AbstractSQLDriverTest
|
class SQLiteDriverTest extends AbstractSQLDriverTest
|
||||||
{
|
{
|
||||||
const DRIVER_CLASS = SQLiteDriver::class;
|
const DRIVER_CLASS = SQLiteDriver::class;
|
||||||
const DRIVER_DSN = 'sqlite:'.__DIR__.'/driver.test.sqlite';
|
|
||||||
const DRIVER_USERNAME = 'root';
|
|
||||||
const DRIVER_PASSWORD = '';
|
|
||||||
const DRIVER_OPTIONS = null;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
@unlink(__DIR__.'/driver.test.sqlite');
|
@unlink(__DIR__ . '/driver.test.sqlite');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function DRIVER_DSN()
|
||||||
|
{
|
||||||
|
return 'sqlite:' . __DIR__ . '/driver.test.sqlite';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_DBNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function DRIVER_USERNAME()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue