Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sandbox container for run tests #45

Draft
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM php:8.0

RUN apt-get -y update \
&& apt-get install -y gnupg2 \
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get -y update \
&& apt-get upgrade -y \
&& ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev libpq-dev \
&& docker-php-ext-install pdo pdo_mysql pgsql pdo_pgsql

RUN pecl install sqlsrv \
&& pecl install pdo_sqlsrv \
&& docker-php-ext-enable sqlsrv pdo_sqlsrv

ENV TEST_ENV=local

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /app
8 changes: 8 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Run Tests
---

To run the tests, you need to run the command in the tests folder

```shell
docker-compose run --rm sandbox vendor/bin/phpunit
```
25 changes: 13 additions & 12 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
declare(strict_types=1);

use Cycle\Database\Config;
use Cycle\Schema\Tests\BaseTest;

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', '1');
Expand All @@ -24,8 +25,8 @@
'mysql' => new Config\MySQLDriverConfig(
connection: new Config\MySQL\TcpConnectionConfig(
database: 'spiral',
host: '127.0.0.1',
port: 13306,
host: getenv('TEST_ENV') === 'local' ? 'mysql_latest' : '127.0.0.1',
port: getenv('TEST_ENV') === 'local' ? 3306 : 13306,
user: 'root',
password: 'root',
),
Expand All @@ -34,8 +35,8 @@
'postgres' => new Config\PostgresDriverConfig(
connection: new Config\Postgres\TcpConnectionConfig(
database: 'spiral',
host: '127.0.0.1',
port: 15432,
host: getenv('TEST_ENV') === 'local' ? 'postgres' : '127.0.0.1',
port: getenv('TEST_ENV') === 'local' ? 5432 : 15432,
user: 'postgres',
password: 'postgres',
),
Expand All @@ -45,8 +46,8 @@
'sqlserver' => new Config\SQLServerDriverConfig(
connection: new Config\SQLServer\TcpConnectionConfig(
database: 'tempdb',
host: '127.0.0.1',
port: 11433,
host: getenv('TEST_ENV') === 'local' ? 'sqlserver' : '127.0.0.1',
port: getenv('TEST_ENV') === 'local' ? 1433 : 11433,
user: 'SA',
password: 'SSpaSS__1'
),
Expand All @@ -55,12 +56,12 @@
];

$db = getenv('DB') ?: null;
\Cycle\Schema\Tests\BaseTest::$config = [
'debug' => false,
'strict' => true,
'benchmark' => true,
] + (
BaseTest::$config = [
'debug' => false,
'strict' => true,
'benchmark' => true,
] + (
$db === null
? $drivers
: array_intersect_key($drivers, array_flip((array)$db))
);
);
15 changes: 14 additions & 1 deletion tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
version: "3"

services:
sandbox:
build: .
volumes:
- ..:/app
depends_on:
- sqlserver
- mysql_latest
- postgres
links:
- sqlserver
- mysql_latest
- postgres

sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
Expand Down Expand Up @@ -28,4 +41,4 @@ services:
environment:
POSTGRES_DB: "spiral"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_PASSWORD: "postgres"
5 changes: 0 additions & 5 deletions tests/fix-binlog.sh

This file was deleted.

9 changes: 0 additions & 9 deletions tests/install-pgsql-10.sh

This file was deleted.

7 changes: 0 additions & 7 deletions tests/install-sqlsrv.sh

This file was deleted.