Skip to content

Commit

Permalink
Create acceptance tests
Browse files Browse the repository at this point in the history
We need these so that we have a final test batch against exactly the
final image that will be running in production, without the extra
dependencies needed to run unit/integration/functional tests.
  • Loading branch information
hgraca committed May 2, 2018
1 parent b0c561e commit 92cc3f0
Show file tree
Hide file tree
Showing 18 changed files with 3,276 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/blog.sqlite
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###

# hostname to use when running the acceptance tests
ACCEPTANCE_TESTS_HOST="localhost"
3 changes: 3 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

$fileHeaderComment = <<<COMMENT
This file is part of the Symfony package.
Expand All @@ -15,6 +17,7 @@ $finder = PhpCsFixer\Finder::create()
->exclude('var')
->exclude('public/bundles')
->exclude('public/build')
->exclude('tests/_support/_generated')
;

return PhpCsFixer\Config::create()
Expand Down
6 changes: 2 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ build:
environment:
variables:
ENV: 'ci'
ACCEPTANCE_TESTS_PORT: 80
mysql: false
postgresql: false
redis: false
Expand All @@ -18,12 +19,9 @@ build:
- 'php:7.1-alpine'
- 'hgraca/explicit-architecture:app.sfn.base'

dependencies:
override:
- true # so scrutinizer does't install the dependencies, which we don't need because they are inside the container

tests:
override:
- command: export ACCEPTANCE_TESTS_HOST=$DOCKER_IP
- command: make test-ci
coverage:
file: var/coverage.clover.xml
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,33 @@ test:
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='tst' ./bin/run
ENV='tst' ./bin/run make db-setup-guest
ENV='tst' ./bin/run php vendor/bin/phpunit
$(MAKE) cs-fix
ENV='tst' ./bin/run php vendor/bin/phpunit
ENV='tst' ./bin/stop
$(MAKE) test-acc

test-acc:
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='tst' ./bin/run make db-setup-guest
ENV='tst' docker-compose -f build/container/tst/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
ENV='tst' ./bin/stop

test-acc-ci:
- ENV='prd' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='prd' docker-compose -f build/container/prd/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
ENV='prd' ./bin/stop

test-ci:
$(MAKE) box-build-prd
$(MAKE) box-build-ci # This is always run by default in the Ci, but having it here makes it possible to run in dev
ENV='ci' ./bin/run
ENV='ci' ./bin/run make db-setup-guest
ENV='ci' ./bin/run php vendor/bin/php-cs-fixer fix --verbose --dry-run
ENV='ci' ./bin/run make test_cov-guest
docker exec -it app.sfn.ci cat ${COVERAGE_REPORT_PATH} > ${COVERAGE_REPORT_PATH}
ENV='ci' ./bin/run php vendor/bin/php-cs-fixer fix --verbose --dry-run
$(MAKE) test-acc-ci

test_cov:
ENV='tst' ./bin/run make test_cov-guest
Expand Down
3 changes: 2 additions & 1 deletion build/container/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ services:
dockerfile: ./build/container/dev/app.dockerfile
tty: true # fix for symfony saying: "proc_open(/dev/tty): failed to open stream: No such device or address"
ports:
- '80:8000' # This way we can run the application locally at http://localhost
# This way we can run the application locally at http://localhost:8000, and run ACC tests against PRD in port 80
- '80:8000'
volumes:
- ../../../:/opt/app
- ~/.composer:/.composer # so we can use the host composer cache
Expand Down
2 changes: 2 additions & 0 deletions build/container/tst/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ services:
- ~/.composer:/.composer # so we can use the host composer cache
- ./php.ini:/usr/local/etc/php/php.ini # so we can easily change php config
- ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini # so we can easily change xdebug config
ports:
- '8000:8000'
environment:
PHP_IDE_CONFIG: 'serverName=docker' # This is needed to debug from CLI (ie. while running tests)
ENV: 'tst'
Expand Down
13 changes: 13 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
params:
- .env # load params from .env file
- env # load params from environment
paths:
tests: tests
output: var/acc_tests/output
data: tests/Fixture
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"white-october/pagerfanta-bundle": "^1.1"
},
"require-dev": {
"codeception/codeception": "^2.4",
"dama/doctrine-test-bundle": "^5.0",
"friendsofphp/php-cs-fixer": "^2.7",
"phpunit/phpunit": "^7.0",
Expand Down
Loading

0 comments on commit 92cc3f0

Please sign in to comment.