Skip to content

Commit 92cc3f0

Browse files
committed
Create acceptance tests
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.
1 parent b0c561e commit 92cc3f0

18 files changed

+3276
-10
lines changed

.env.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/blog.sqlite
2323
# Delivery is disabled by default via "null://localhost"
2424
MAILER_URL=null://localhost
2525
###< symfony/swiftmailer-bundle ###
26+
27+
# hostname to use when running the acceptance tests
28+
ACCEPTANCE_TESTS_HOST="localhost"

.php_cs.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$fileHeaderComment = <<<COMMENT
46
This file is part of the Symfony package.
57
@@ -15,6 +17,7 @@ $finder = PhpCsFixer\Finder::create()
1517
->exclude('var')
1618
->exclude('public/bundles')
1719
->exclude('public/build')
20+
->exclude('tests/_support/_generated')
1821
;
1922

2023
return PhpCsFixer\Config::create()

.scrutinizer.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ build:
33
environment:
44
variables:
55
ENV: 'ci'
6+
ACCEPTANCE_TESTS_PORT: 80
67
mysql: false
78
postgresql: false
89
redis: false
@@ -18,12 +19,9 @@ build:
1819
- 'php:7.1-alpine'
1920
- 'hgraca/explicit-architecture:app.sfn.base'
2021

21-
dependencies:
22-
override:
23-
- true # so scrutinizer does't install the dependencies, which we don't need because they are inside the container
24-
2522
tests:
2623
override:
24+
- command: export ACCEPTANCE_TESTS_HOST=$DOCKER_IP
2725
- command: make test-ci
2826
coverage:
2927
file: var/coverage.clover.xml

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,33 @@ test:
105105
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
106106
ENV='tst' ./bin/run
107107
ENV='tst' ./bin/run make db-setup-guest
108-
ENV='tst' ./bin/run php vendor/bin/phpunit
109108
$(MAKE) cs-fix
109+
ENV='tst' ./bin/run php vendor/bin/phpunit
110110
ENV='tst' ./bin/stop
111+
$(MAKE) test-acc
112+
113+
test-acc:
114+
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
115+
ENV='tst' ./bin/run make db-setup-guest
116+
ENV='tst' docker-compose -f build/container/tst/docker-compose.yml up -d -t 0
117+
php vendor/bin/codecept run acceptance
118+
ENV='tst' ./bin/stop
119+
120+
test-acc-ci:
121+
- ENV='prd' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
122+
ENV='prd' docker-compose -f build/container/prd/docker-compose.yml up -d -t 0
123+
php vendor/bin/codecept run acceptance
124+
ENV='prd' ./bin/stop
111125

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

121136
test_cov:
122137
ENV='tst' ./bin/run make test_cov-guest

build/container/dev/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ services:
1010
dockerfile: ./build/container/dev/app.dockerfile
1111
tty: true # fix for symfony saying: "proc_open(/dev/tty): failed to open stream: No such device or address"
1212
ports:
13-
- '80:8000' # This way we can run the application locally at http://localhost
13+
# This way we can run the application locally at http://localhost:8000, and run ACC tests against PRD in port 80
14+
- '80:8000'
1415
volumes:
1516
- ../../../:/opt/app
1617
- ~/.composer:/.composer # so we can use the host composer cache

build/container/tst/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ services:
1414
- ~/.composer:/.composer # so we can use the host composer cache
1515
- ./php.ini:/usr/local/etc/php/php.ini # so we can easily change php config
1616
- ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini # so we can easily change xdebug config
17+
ports:
18+
- '8000:8000'
1719
environment:
1820
PHP_IDE_CONFIG: 'serverName=docker' # This is needed to debug from CLI (ie. while running tests)
1921
ENV: 'tst'

codeception.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
params:
2+
- .env # load params from .env file
3+
- env # load params from environment
4+
paths:
5+
tests: tests
6+
output: var/acc_tests/output
7+
data: tests/Fixture
8+
support: tests/_support
9+
envs: tests/_envs
10+
actor_suffix: Tester
11+
extensions:
12+
enabled:
13+
- Codeception\Extension\RunFailed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"white-october/pagerfanta-bundle": "^1.1"
3333
},
3434
"require-dev": {
35+
"codeception/codeception": "^2.4",
3536
"dama/doctrine-test-bundle": "^5.0",
3637
"friendsofphp/php-cs-fixer": "^2.7",
3738
"phpunit/phpunit": "^7.0",

0 commit comments

Comments
 (0)