diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index a001700..12ad553 100644 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -2,7 +2,7 @@ cd /var/www/html -if [ "$1" = 'bash' ] +if [ "$1" = "bash" ] || [ "$1" = "composer" ] then exec "$@" exit 0 @@ -28,6 +28,11 @@ then cp -r ./../dist ./frontend/dist fi -wait-for-it db:3306 -- "./yii migrate/up --interactive=0" +if [ "$YII_ENV" != "test" ] +then + wait-for-it db:3306 -- "php /var/www/html/yii migrate/up --interactive=0" +else + wait-for-it testdb:3306 -- "php /var/www/html/tests/codeception/bin/yii migrate/up --interactive=0" +fi exec "$@" diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index e2faa61..e7ea80c 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,17 +1,26 @@ version: '2' services: testphp: - extends: - file: ../docker-compose.dev.yml - service: app + container_name: accountelyby_testphp + build: + context: ../ + dockerfile: Dockerfile-dev + depends_on: + - testdb + - testredis + - testrabbit volumes: - ./../:/var/www/html/ - env_file: ./../.env + environment: + - YII_DEBUG=true + - YII_ENV=test + # Это я потом, когда-нибудь, уберу + - XDEBUG_CONFIG=remote_host=10.254.254.254 + - PHP_IDE_CONFIG=serverName=docker testdb: - extends: - file: ../docker-compose.dev.yml - service: db + container_name: accountelyby_testdb + build: ./../docker/mariadb environment: MYSQL_ROOT_PASSWORD: "" MYSQL_ALLOW_EMPTY_PASSWORD: "yes" @@ -20,14 +29,12 @@ services: MYSQL_PASSWORD: "ely_accounts_tester_password" testredis: - extends: - file: ../docker-compose.dev.yml - service: redis + container_name: accountelyby_testredis + image: redis:3.0-alpine testrabbit: - extends: - file: ../docker-compose.dev.yml - service: rabbitmq + container_name: accountelyby_testrabbit + image: rabbitmq:3.6 environment: RABBITMQ_DEFAULT_USER: "ely-accounts-tester" RABBITMQ_DEFAULT_PASS: "tester-password" diff --git a/tests/php.sh b/tests/php.sh index 6a4d4be..c6a53a2 100755 --- a/tests/php.sh +++ b/tests/php.sh @@ -3,6 +3,4 @@ cd "$(dirname "$0")" ./../vendor/bin/codecept build - -./../docker/wait-for-it.sh testdb:3306 testrabbit:5672 -- \ -php codeception/bin/yii migrate/up --interactive=0 && ./../vendor/bin/codecept run $* +./../vendor/bin/codecept run $*