Skip to content

Commit

Permalink
configure test database
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmnk committed Apr 6, 2024
1 parent a24e1b9 commit da28b4d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/resources/lang/la
/resources/lang/sp
/vendor
/data
.env
.env.backup
.phpunit.result.cache
Expand Down
12 changes: 0 additions & 12 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
],

/*
Expand Down
66 changes: 19 additions & 47 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="DB_PORT" value="8011"/> <!-- overriding default database port -->
</php>
<source>
<include>
Expand Down

0 comments on commit da28b4d

Please sign in to comment.