From da28b4d30af242230651cdb69474d170723da596 Mon Sep 17 00:00:00 2001 From: kdmnk Date: Sat, 6 Apr 2024 12:18:43 +0200 Subject: [PATCH] configure test database --- .gitignore | 1 + config/database.php | 12 --------- docker-compose.yml | 66 +++++++++++++-------------------------------- phpunit.xml | 1 + 4 files changed, 21 insertions(+), 59 deletions(-) diff --git a/.gitignore b/.gitignore index af039d7a1..21096d4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ /resources/lang/la /resources/lang/sp /vendor +/data .env .env.backup .phpunit.result.cache diff --git a/config/database.php b/config/database.php index bcf1632e4..89a1355bb 100644 --- a/config/database.php +++ b/config/database.php @@ -90,18 +90,6 @@ 'prefix' => '', 'prefix_indexes' => true, ], - - 'testing' => [ - 'driver' => 'mysql', - 'host' => env('DB_TEST_HOST', 'localhost'), - 'database' => env('DB_TEST_DATABASE', 'homestead'), - 'username' => env('DB_TEST_USERNAME', 'homestead'), - 'password' => env('DB_TEST_PASSWORD', 'secret'), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - 'strict' => false, - ], ], /* diff --git a/docker-compose.yml b/docker-compose.yml index eb723dbd2..2c2378e6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,56 +1,28 @@ -# For more information: https://laravel.com/docs/sail +# DB_CONNECTION=mysql +# DB_HOST=127.0.0.1 +# DB_PORT=3306 (overriden by 8011 for tests) + version: '3' services: - laravel.test: - build: - context: ./vendor/laravel/sail/runtimes/8.2 - dockerfile: Dockerfile - args: - WWWGROUP: '${WWWGROUP}' - image: sail-8.2/app - extra_hosts: - - 'host.docker.internal:host-gateway' - ports: - - '${APP_PORT:-80}:80' - - '${VITE_PORT:-5173}:${VITE_PORT:-5173}' + mars_mysql: + container_name: mars_mysql + image: 'mysql:8.3' environment: - WWWUSER: '${WWWUSER}' - LARAVEL_SAIL: 1 - XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' - XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' - volumes: - - '.:/var/www/html' - networks: - - sail - depends_on: - - mysql - mysql: - image: 'mysql/mysql-server:8.0' + MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' + MYSQL_DATABASE: '${DB_DATABASE}' + MYSQL_USER: '${DB_USERNAME}' + MYSQL_PASSWORD: '${DB_PASSWORD}' ports: - - '${FORWARD_DB_PORT:-3306}:3306' + - '127.0.0.1:3306:3306' + volumes: + - './data/mysql:/var/lib/mysql' + mars_mysql_test: + container_name: mars_mysql_test + image: 'mysql:8.3' environment: MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_ROOT_HOST: '%' MYSQL_DATABASE: '${DB_DATABASE}' MYSQL_USER: '${DB_USERNAME}' MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 1 - volumes: - - 'sail-mysql:/var/lib/mysql' - - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' - networks: - - sail - healthcheck: - test: - - CMD - - mysqladmin - - ping - - '-p${DB_PASSWORD}' - retries: 3 - timeout: 5s -networks: - sail: - driver: bridge -volumes: - sail-mysql: - driver: local + ports: + - '127.0.0.1:8011:3306' diff --git a/phpunit.xml b/phpunit.xml index c8b8b7652..250c7bc31 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -15,6 +15,7 @@ +