From 8f4e42d3912ad974b4314a37eeba6ca2ec071845 Mon Sep 17 00:00:00 2001 From: Igor Mukhin Date: Mon, 16 Sep 2019 20:20:51 +0300 Subject: [PATCH] Improved: Composer scripts to run behat tests as well --- composer.json | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f970b7e..3163bd3 100644 --- a/composer.json +++ b/composer.json @@ -74,17 +74,58 @@ "@tests" ], "analyse": "vendor/bin/phpstan analyse -c phpstan.neon -l max src/", + "assets": [ + "@ensure-assets-installed", + "@ensure-assets-compiled" + ], + "behat": [ + "SYMFONY_ENV=test composer ensure-database-ready", + "SYMFONY_ENV=test composer ensure-env-copied", + "vendor/bin/behat --tags=\"~@javascript\" --no-interaction --format=progress" + ], "check-style": "vendor/bin/ecs check src/ spec/", "checks": [ + "composer validate --strict", + "composer normalize --dry-run", "@check-style", "@analyse" ], + "ensure-assets-compiled": "[[ -d tests/Application/public/assets ]] || (cd tests/Application && yarn build && composer ensure-env-copied && bin/console assets:install public -e ${SYMFONY_ENV:-'dev'})", + "ensure-assets-installed": "[[ -d tests/Application/node_modules ]] || (cd tests/Application && yarn install)", + "ensure-database-created": "composer ensure-env-copied && (cd tests/Application && bin/console doctrine:database:create --if-not-exists -e ${SYMFONY_ENV:-'dev'})", + "ensure-database-ready": [ + "@ensure-database-created", + "@ensure-schema-updated" + ], + "ensure-env-copied": "([[ ${SYMFONY_ENV:-'dev'} == 'dev' ]] && composer ensure-env-dev-copied) || ([[ ${SYMFONY_ENV:-'dev'} == 'test' ]] && composer ensure-env-test-copied) || echo 'Unknown environment ${SYMFONY_ENV}'", + "ensure-env-dev-copied": "(cd tests/Application && ([[ -f .env.dev.local ]] || cp .env .env.dev.local))", + "ensure-env-test-copied": "(cd tests/Application && ([[ -f .env.test.local ]] || cp .env.test .env.test.local))", + "ensure-schema-updated": "composer ensure-env-copied && (cd tests/Application && bin/console doctrine:schema:update --force -e ${SYMFONY_ENV:-'dev'})", + "ensure-vendors-installed": "[[ -f vendor/autoload.php ]] || php -d memory_limit=-1 /usr/local/bin/composer install", "fix-style": "vendor/bin/ecs check src/ spec/ --fix", + "fixtures": [ + "@ensure-database-ready", + "(cd tests/Application && bin/console sylius:fixtures:load --no-interaction -e ${SYMFONY_ENV:-'dev'})" + ], "phpspec": "vendor/bin/phpspec run", - "phpunit": "vendor/bin/phpunit", + "phpunit": [ + "SYMFONY_ENV=test composer ensure-database-ready", + "vendor/bin/phpunit" + ], + "run": [ + "@ensure-env-copied", + "(cd tests/Application && bin/console server:run -d public -e ${SYMFONY_ENV:-'dev'})" + ], "tests": [ "@phpspec", - "@phpunit" + "@phpunit", + "@behat" + ], + "try": [ + "@ensure-vendors-installed", + "@assets", + "@fixtures", + "@run" ] } }