Skip to content

Commit

Permalink
test: not working with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Faez-B committed Jun 30, 2024
1 parent 5e32d7e commit 59bc5b3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
APP_ENV=test
DATABASE_URL="mysql://symfony:symfony@database:3306/symfony"
DATABASE_URL="mysql://symfony_test:symfony_test@database:3306/symfony_test?serverVersion=8.4&charset=utf8mb4"
2 changes: 1 addition & 1 deletion .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DATABASE_URL: mysql://root:test@database/main_test?serverVersion=8&charset=utf8mb4"
DATABASE_URL: mysql://symfony_test:symfony_test@database:3306/symfony_test?serverVersion=8.4&charset=utf8mb4
run: ./bin/phpunit
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
ca-certificates \
gnupg

RUN docker-php-ext-install pdo pdo_mysql zip

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions mbstring apcu opcache intl zip pdo pdo_mysql
Expand Down
30 changes: 18 additions & 12 deletions compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
services:
###> doctrine/doctrine-bundle ###
# database_test:
# image: mysql:8.4
# container_name: database_test
# environment:
# MYSQL_ROOT_PASSWORD: symfony
# MYSQL_DATABASE: symfony_test
# ports:
# - 3306
database_test:
image: mysql:8.4
container_name: database_test
environment:
MYSQL_ROOT_PASSWORD: symfony_test
MYSQL_DATABASE: symfony_test
MYSQL_USER: symfony_test
MYSQL_PASSWORD: symfony_test
ports:
- 3306
volumes:
- ./docker/conf/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
networks:
- symfony
###< doctrine/doctrine-bundle ###

###> symfony/mailer ###
mailer:
image: schickling/mailcatcher
container_name: mailer
ports: [1025, 1080]
# mailer:
# image: schickling/mailcatcher
# container_name: mailer
# ports: [1025, 1080]
###< symfony/mailer ###
4 changes: 3 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
MYSQL_USER: symfony
MYSQL_PASSWORD: symfony
ports:
- "3306:3306"
- 3306
volumes:
- ./docker/volumes/data:/var/lib/mysql
# - ./docker/conf/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
Expand All @@ -34,6 +34,8 @@ services:
- '8080:80'
depends_on:
- database
networks:
- symfony

volumes:
data:
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/EnergieControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EnergieControllerTest extends WebTestCase

protected function setUp(): void
{
// $this->client = static::createClient();
$this->client = static::createClient();
$this->repository = (static::getContainer()->get('doctrine'))->getRepository(Energie::class);

foreach ($this->repository->findAll() as $object) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/MarqueControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MarqueControllerTest extends WebTestCase

protected function setUp(): void
{
// $this->client = static::createClient();
$this->client = static::createClient();
$this->repository = (static::getContainer()->get('doctrine'))->getRepository(Marque::class);

foreach ($this->repository->findAll() as $object) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/VoitureControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class VoitureControllerTest extends WebTestCase

protected function setUp(): void
{
// $this->client = static::createClient();
$this->client = static::createClient();
$this->repository = (static::getContainer()->get('doctrine'))->getRepository(Voiture::class);

foreach ($this->repository->findAll() as $object) {
Expand Down

0 comments on commit 59bc5b3

Please sign in to comment.