Skip to content

Commit 8aa82bb

Browse files
committed
Add behat tests
1 parent bc9c7c3 commit 8aa82bb

15 files changed

+1256
-61
lines changed

.env.test

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is a "template" of which env vars need to be defined for your application
2+
# Copy this file to .env file for development, create environment variables when deploying to production
3+
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
4+
5+
###> symfony/framework-bundle ###
6+
APP_ENV=test
7+
8+
DATABASE_NAME=symfony-rest-api-init-test
9+
DATABASE_URL=mysql://root:root@database/${DATABASE_NAME}
10+
###< doctrine/doctrine-bundle ###
11+
12+
RELEASE_NAME='local-test'
13+
14+
####> lexik/jwt-authentication-bundle ###
15+
#JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
16+
#JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
17+
#JWT_PASSPHRASE=2d6e32416f8180d4b5a96ab3cb4cb8e6
18+
####< lexik/jwt-authentication-bundle ###

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@
3838
.idea/
3939
/docker-compose.override.yml
4040
/docker/mysql
41-
config/firebase/service-account.json
41+
config/firebase/service-account.json
42+
###> friends-of-behat/symfony-extension ###
43+
/behat.yml
44+
###< friends-of-behat/symfony-extension ###

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ db-fixtures: ## Reset the database fixtures
7373
## TESTS
7474
##
7575

76-
unit-tests: ## Run functional tests
76+
unit-tests: ## Run unit tests
7777
$(EXEC) bin/phpunit
7878

7979
unit-tests-coverage: ## Run functional tests
8080
$(EXEC) bin/phpunit --coverage-html public/coverage
8181

82+
behat-tests: ## Run behat tests
83+
$(EXEC) vendor/bin/behat
84+
8285
##
8386
## Tools
8487
##---------------------------------------------------------------------------

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This is an open source project to initialize any restful symfony project. It is
1616
- JWT
1717
- Validation
1818
- Unit tests
19+
- Behat tests
1920
- Custom Normalizer
2021
- Database migrations
2122
- Documentation with Swagger
@@ -119,6 +120,12 @@ make unit-test-coverage
119120

120121
The coverage report will be accessible at `public/coverage/index.html`
121122

123+
#### Run the behat tests(optional)
124+
125+
```bash
126+
make behat-test
127+
```
128+
122129
### Usage
123130

124131
API root URL : [http://localhost:8080](http://localhost:8080)

behat.yml.dist

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- App\Tests\Behat\FeatureContext
6+
- behatch:context:json
7+
- Behat\MinkExtension\Context\MinkContext
8+
9+
extensions:
10+
FriendsOfBehat\SymfonyExtension:
11+
bootstrap: features/bootstrap/bootstrap.php
12+
kernel:
13+
class: App\Kernel
14+
environment: test
15+
debug: ~
16+
Behatch\Extension: ~
17+
Behat\MinkExtension:
18+
sessions:
19+
default:
20+
symfony: ~
21+
AdamQuaile\Behat\CommandRunnerExtension:
22+
beforeFeature:
23+
- bin/console --env=test doctrine:database:drop --force --if-exists
24+
- bin/console --env=test doctrine:database:create
25+
- bin/console --env=test doctrine:migrations:migrate -n
26+
afterSuite:
27+
- bin/console --env=test doctrine:database:drop --force --if-exists

composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"symfony/yaml": "^5.1"
3131
},
3232
"require-dev": {
33+
"adamquaile/behat-command-runner-extension": "*@dev",
34+
"behat/behat": "^3.7",
35+
"behatch/contexts": "^3.3",
36+
"friends-of-behat/mink-browserkit-driver": "^1.4",
37+
"friends-of-behat/symfony-extension": "^2.1",
3338
"friendsofphp/php-cs-fixer": "^2.16",
3439
"hautelook/alice-bundle": "^2.7",
3540
"nelmio/api-doc-bundle": "^3.3",

0 commit comments

Comments
 (0)