Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codeception; improve functional tests #319

Merged
merged 17 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
SYMFONY_DEPRECATIONS_HELPER=weak
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

APP_SECURITY_OAUTH_DISCORD_SERVER_ID=

APP_SECURITY_API_ALLOWED_KEYS=test_key

APP_URL_TEAMSPEAK='teamspeak.example.com'
APP_URL_TEAMSPEAK='ts3server://ts.localhost.com?password=test'
6 changes: 3 additions & 3 deletions .github/workflows/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
docker compose -f docker-compose.test.yml up --wait
docker compose exec -T php composer install

- name: Setup database
- name: Setup tests
run: |
make db env=test
make test-setup

- name: Run lint
run: |
Expand All @@ -40,7 +40,7 @@ jobs:

- name: Run tests
run: |
make test-ci
make test

- name: Failure logs
if: failure()
Expand Down
15 changes: 9 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('var')
->exclude('node_modules')
->notPath('config/bundles.php')
Expand All @@ -11,7 +12,11 @@
->notPath('public/index.php')
->notPath('src/Kernel.php')
->notPath('tests/bootstrap.php')
->in(__DIR__)

# Codeception
->exclude('tests/_data')
->exclude('tests/_output')
->exclude('tests/_support/_generated')
;

return (new PhpCsFixer\Config())
Expand All @@ -26,12 +31,11 @@
'@PHP80Migration' => true,
'@PHP80Migration:risky' => true,

'php_unit_test_annotation' => [
'style' => 'annotation',
],
'php_unit_internal_class' => false,
'php_unit_method_casing' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_separation' => false,
'phpdoc_to_comment' => false,
'ordered_traits' => false,
'ordered_class_elements' => [
'order' => [
'use_trait', // traits
Expand Down Expand Up @@ -64,7 +68,6 @@
],
'sort_algorithm' => 'none',
],
'phpdoc_separation' => false
])
->setFinder($finder)
;
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ db:
docker-compose exec -T php php bin/console doctrine:database:create --if-not-exists --env=${env}
docker-compose exec -T php php bin/console doctrine:migration:migrate --no-interaction --env=${env}

docker-compose exec -T php php bin/console doctrine:fixtures:load --no-interaction --env=${env}

console:
@docker-compose exec php sh

setup:
@make db
docker-compose exec -T php php bin/console app:import:modlists var/import

test:
test-setup:
@make db env=test
@make test-ci
docker-compose exec -T php php vendor/bin/codecept clean
docker-compose exec -T php php vendor/bin/codecept build

test-ci:
docker-compose exec -T php php bin/console doctrine:fixtures:load --no-interaction --env=test

docker-compose exec -T php php bin/phpunit --testdox
test:
docker-compose exec -T php php vendor/bin/codecept run unit,integration,functional --fail-fast
14 changes: 14 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace: App\Tests
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
params:
- .env
- .env.test
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"wohali/oauth2-discord-new": "^1.2"
},
"require-dev": {
"codeception/codeception": "^5.0",
"codeception/module-asserts": "^3.0",
"codeception/module-doctrine2": "^3.0",
"codeception/module-rest": "^3.3",
"codeception/module-symfony": "^3.2",
"dama/doctrine-test-bundle": "^7.2",
"friendsofphp/php-cs-fixer": "^3.23",
"phpstan/phpstan": "^1.10",
Expand Down Expand Up @@ -90,6 +95,7 @@
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/_support/",
"App\\Tests\\Unit\\": "tests/unit",
"App\\Tests\\Integration\\": "tests/integration",
"App\\Tests\\Functional\\": "tests/functional"
Expand Down
Loading
Loading