Skip to content

Commit 11411c2

Browse files
committed
Allow execution via PHPUnit
1 parent 6cfa3e4 commit 11411c2

File tree

73 files changed

+3222
-778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3222
-778
lines changed

.github/workflows/main.yml

Lines changed: 35 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -6,132 +6,57 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
php: [8.2, 8.3, 8.4, 8.5]
10-
symfony: ["5.4.*", "6.4.*", "6.4wApi", "7.3.*", "7.4.*"]
11-
env:
12-
only_sf_latest: &only_sf_latest ${{ matrix.symfony == '7.4.*' }}
9+
php: ["8.2", "8.5"]
10+
symfony: ["5.4", "6.4", "7.4", "8.0"]
11+
exclude:
12+
- php: "8.2"
13+
symfony: "8.0"
1314

1415
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v6
16+
- uses: actions/checkout@v6
1717

18-
- name: Setup PHP != 8.5
19-
if: ${{ matrix.php != '8.5' }}
20-
uses: shivammathur/setup-php@v2
18+
- uses: shivammathur/setup-php@v2
2119
with:
2220
php-version: ${{ matrix.php }}
23-
tools: composer:v2
24-
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite
25-
coverage: none
21+
coverage: pcov
2622

27-
- name: Setup PHP 8.5
28-
if: ${{ matrix.php == '8.5' }}
29-
uses: shivammathur/setup-php@v2
23+
- uses: actions/cache@v5
3024
with:
31-
php-version: ${{ matrix.php }}
32-
tools: composer:v2
33-
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite
34-
coverage: none
35-
# this ini directive seems to be off by default in PHP 8.5
36-
# see https://github.com/php/php-src/issues/20279
37-
# enable it because codeception relies on it.
38-
ini-values: register_argc_argv=1
39-
40-
- name: Set Symfony version reference
41-
env:
42-
MATRIX_SYMFONY: ${{ matrix.symfony }}
43-
run: |
44-
if [[ "$MATRIX_SYMFONY" == *'*' ]]; then
45-
echo "SF_REF=${MATRIX_SYMFONY%.*}" >> "$GITHUB_ENV"
46-
else
47-
echo "SF_REF=$MATRIX_SYMFONY" >> "$GITHUB_ENV"
48-
fi
49-
50-
- name: Set Composer Symfony constraint
51-
env:
52-
MATRIX_SYMFONY: ${{ matrix.symfony }}
53-
run: |
54-
if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then
55-
echo "COMP_SYMFONY=6.4.*" >> "$GITHUB_ENV"
56-
else
57-
echo "COMP_SYMFONY=$MATRIX_SYMFONY" >> "$GITHUB_ENV"
58-
fi
25+
path: ~/.cache/composer
26+
key: php-${{ matrix.php }}-sf-${{ matrix.symfony }}-${{ hashFiles('**/composer.json') }}
27+
restore-keys: php-${{ matrix.php }}-sf-${{ matrix.symfony }}-
5928

60-
- name: Checkout Symfony ${{ env.SF_REF }} sample
61-
uses: actions/checkout@v4
29+
- uses: actions/checkout@v6
30+
name: Checkout Symfony ${{ matrix.symfony }} app
6231
with:
6332
repository: Codeception/symfony-module-tests
6433
path: framework-tests
65-
ref: ${{ env.SF_REF }}
66-
67-
- name: Get composer cache directory
68-
id: composer-cache
69-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
70-
71-
- name: Cache Composer dependencies
72-
uses: actions/cache@v3
73-
with:
74-
path: ${{ steps.composer-cache.outputs.dir }}
75-
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.{json,lock}') }}
76-
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
77-
78-
- name: Install PHPUnit 10
79-
run: composer require --dev --no-update phpunit/phpunit:^10.0
34+
ref: ${{ matrix.symfony }}
8035

8136
- name: Install dependencies
82-
env:
83-
MATRIX_SYMFONY: ${{ matrix.symfony }}
84-
run: |
85-
composer require --no-update \
86-
symfony/{finder,yaml,console,event-dispatcher,css-selector,dom-crawler,browser-kit}:${{ env.COMP_SYMFONY }} \
87-
vlucas/phpdotenv \
88-
codeception/module-asserts:"3.*" \
89-
codeception/module-doctrine:"3.*"
90-
91-
if [[ "$MATRIX_SYMFONY" == "6.4wApi" ]]; then
92-
composer require codeception/module-rest="3.*" --no-update
93-
fi
94-
95-
composer update --prefer-dist --no-progress
96-
97-
- name: Run PHPStan (max)
98-
if: *only_sf_latest
99-
run: composer phpstan
100-
101-
- name: Run PHP-CS-Fixer
102-
if: *only_sf_latest
103-
run: composer cs-check
104-
105-
- name: Run Composer Audit
106-
if: *only_sf_latest
107-
run: composer audit
108-
109-
- name: Validate Composer files
110-
run: composer validate --strict
111-
working-directory: framework-tests
112-
113-
- name: Install PHPUnit in framework-tests
114-
run: composer require --dev --no-update phpunit/phpunit:^10.0
115-
working-directory: framework-tests
116-
117-
- name: Prepare Symfony sample
11837
run: |
119-
composer remove codeception/codeception codeception/module-asserts codeception/module-doctrine codeception/lib-innerbrowser codeception/module-symfony --dev --no-update
120-
composer update --no-progress
121-
working-directory: framework-tests
38+
sed -i "s/\^5.4 | \^6.4 | \^7.4 | \^8.0/${{ matrix.symfony }}.*/g" composer.json
39+
composer install --prefer-dist --no-progress
12240
123-
- name: Setup Database
124-
run: |
125-
php bin/console doctrine:schema:update --force
126-
php bin/console doctrine:fixtures:load --quiet
127-
working-directory: framework-tests
41+
- name: Quality checks
42+
if: matrix.symfony == '8.0'
43+
run: composer validate --strict && composer audit && composer cs-check && composer phpstan
12844

129-
- name: Generate JWT keypair
130-
if: ${{ matrix.symfony == '6.4wApi' }}
131-
run: php bin/console lexik:jwt:generate-keypair --skip-if-exists
132-
working-directory: framework-tests
45+
- name: Run module tests
46+
run: vendor/bin/phpunit tests ${{ matrix.symfony == '8.0' && '--coverage-text --coverage-filter src' || '' }}
13347

134-
- name: Run tests
48+
- name: Prepare Symfony app & run tests
13549
run: |
136-
php vendor/bin/codecept build -c framework-tests
50+
composer -d framework-tests remove codeception/module-symfony --dev --no-update
51+
composer -d framework-tests install --no-progress
52+
php framework-tests/bin/console doctrine:schema:update --force
53+
php framework-tests/bin/console doctrine:fixtures:load --quiet
13754
php vendor/bin/codecept run Functional -c framework-tests
55+
56+
if [ "${{ matrix.symfony }}" = "7.4" ]; then
57+
composer require codeception/module-rest --dev
58+
git -C framework-tests apply resetFormatsAfterRequest_issue_test.patch
59+
composer -d framework-tests install --no-progress
60+
php framework-tests/bin/console lexik:jwt:generate-keypair --skip-if-exists
61+
php vendor/bin/codecept run Functional -c framework-tests
62+
fi

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/vendor/
33
/composer.lock
44
/framework-tests
5-
/.php-cs-fixer.cache
5+
/.php-cs-fixer.cache
6+
var/

.php-cs-fixer.dist.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
8+
9+
return (new Config())
10+
->setParallelConfig(ParallelConfigFactory::detect())
11+
->setRiskyAllowed(true)
12+
->setRules([
13+
'@PER-CS' => true,
14+
'@PHP82Migration' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'strict_param' => true,
17+
'declare_strict_types' => true,
18+
])
19+
->setFinder(
20+
(new Finder())
21+
->in(__DIR__)
22+
->exclude(['var', 'vendor'])
23+
->ignoreDotFiles(true)
24+
->ignoreVCS(true)
25+
)
26+
;

composer.json

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,58 @@
2424
"require": {
2525
"php": "^8.2",
2626
"ext-json": "*",
27-
"codeception/codeception": "^5.3",
28-
"codeception/lib-innerbrowser": "^3.1 | ^4.0"
27+
"codeception/lib-innerbrowser": "^3.1 | ^4.1"
2928
},
3029
"require-dev": {
31-
"codeception/module-asserts": "^3.0",
32-
"codeception/module-doctrine": "^3.1",
33-
"doctrine/orm": "^3.5",
34-
"friendsofphp/php-cs-fixer": "^3.85",
30+
"codeception/module-asserts": "^3.3",
31+
"codeception/module-doctrine": "^3.3",
32+
"doctrine/orm": "^3.6",
33+
"friendsofphp/php-cs-fixer": "^3.94",
3534
"phpstan/phpstan": "^2.1",
36-
"phpunit/phpunit": "^10.0",
37-
"symfony/browser-kit": "^5.4 | ^6.4 | ^7.3 | ^8.0",
38-
"symfony/cache": "^5.4 | ^6.4 | ^7.3 | ^8.0",
39-
"symfony/config": "^5.4 | ^6.4 | ^7.3 | ^8.0",
40-
"symfony/dependency-injection": "^5.4 | ^6.4 | ^7.3 | ^8.0",
41-
"symfony/dom-crawler": "^5.4 | ^6.4 | ^7.3 | ^8.0",
42-
"symfony/dotenv": "^5.4 | ^6.4 | ^7.3 | ^8.0",
43-
"symfony/error-handler": "^5.4 | ^6.4 | ^7.3 | ^8.0",
44-
"symfony/filesystem": "^5.4 | ^6.4 | ^7.3 | ^8.0",
45-
"symfony/form": "^5.4 | ^6.4 | ^7.3 | ^8.0",
46-
"symfony/framework-bundle": "^5.4 | ^6.4 | ^7.3 | ^8.0",
47-
"symfony/http-client": "^5.4 | ^6.4 | ^7.3 | ^8.0",
48-
"symfony/http-foundation": "^5.4 | ^6.4 | ^7.3 | ^8.0",
49-
"symfony/http-kernel": "^5.4 | ^6.4 | ^7.3 | ^8.0",
50-
"symfony/mailer": "^5.4 | ^6.4 | ^7.3 | ^8.0",
51-
"symfony/mime": "^5.4 | ^6.4 | ^7.3 | ^8.0",
52-
"symfony/notifier": "^5.4 | ^6.4 | ^7.3 | ^8.0",
53-
"symfony/options-resolver": "^5.4 | ^6.4 | ^7.3 | ^8.0",
54-
"symfony/property-access": "^5.4 | ^6.4 | ^7.3 | ^8.0",
55-
"symfony/property-info": "^5.4 | ^6.4 | ^7.3 | ^8.0",
56-
"symfony/routing": "^5.4 | ^6.4 | ^7.3 | ^8.0",
57-
"symfony/security-bundle": "^5.4 | ^6.4 | ^7.3 | ^8.0",
58-
"symfony/security-core": "^5.4 | ^6.4 | ^7.3 | ^8.0",
59-
"symfony/security-csrf": "^5.4 | ^6.4 | ^7.3 | ^8.0",
60-
"symfony/security-http": "^5.4 | ^6.4 | ^7.3 | ^8.0",
61-
"symfony/translation": "^5.4 | ^6.4 | ^7.3 | ^8.0",
62-
"symfony/twig-bundle": "^5.4 | ^6.4 | ^7.3 | ^8.0",
63-
"symfony/validator": "^5.4 | ^6.4 | ^7.3 | ^8.0",
64-
"symfony/var-exporter": "^5.4 | ^6.4 | ^7.3 | ^8.0",
65-
"vlucas/phpdotenv": "^4.2 | ^5.4"
35+
"phpunit/phpunit": "^11.0 | ^12.0",
36+
"symfony/browser-kit": "^5.4 | ^6.4 | ^7.4 | ^8.0",
37+
"symfony/cache": "^5.4 | ^6.4 | ^7.4 | ^8.0",
38+
"symfony/clock": "^6.4 | ^7.4 | ^8.0",
39+
"symfony/config": "^5.4 | ^6.4 | ^7.4 | ^8.0",
40+
"symfony/console": "^5.4 | ^6.4 | ^7.4 | ^8.0",
41+
"symfony/css-selector": "^5.4 | ^6.4 | ^7.4 | ^8.0",
42+
"symfony/dependency-injection": "^5.4 | ^6.4 | ^7.4 | ^8.0",
43+
"symfony/dom-crawler": "^5.4 | ^6.4 | ^7.4 | ^8.0",
44+
"symfony/dotenv": "^5.4 | ^6.4 | ^7.4 | ^8.0",
45+
"symfony/error-handler": "^5.4 | ^6.4 | ^7.4 | ^8.0",
46+
"symfony/event-dispatcher": "^5.4 | ^6.4 | ^7.4 | ^8.0",
47+
"symfony/filesystem": "^5.4 | ^6.4 | ^7.4 | ^8.0",
48+
"symfony/finder": "^5.4 | ^6.4 | ^7.4 | ^8.0",
49+
"symfony/form": "^5.4 | ^6.4 | ^7.4 | ^8.0",
50+
"symfony/framework-bundle": "^5.4 | ^6.4 | ^7.4 | ^8.0",
51+
"symfony/http-client": "^5.4 | ^6.4 | ^7.4 | ^8.0",
52+
"symfony/http-foundation": "^5.4 | ^6.4 | ^7.4 | ^8.0",
53+
"symfony/http-kernel": "^5.4 | ^6.4 | ^7.4 | ^8.0",
54+
"symfony/mailer": "^5.4 | ^6.4 | ^7.4 | ^8.0",
55+
"symfony/mime": "^5.4 | ^6.4 | ^7.4 | ^8.0",
56+
"symfony/notifier": "^5.4 | ^6.4 | ^7.4 | ^8.0",
57+
"symfony/options-resolver": "^5.4 | ^6.4 | ^7.4 | ^8.0",
58+
"symfony/password-hasher": "^5.4 | ^6.4 | ^7.4 | ^8.0",
59+
"symfony/process": "^5.4 | ^6.4 | ^7.4 | ^8.0",
60+
"symfony/property-access": "^5.4 | ^6.4 | ^7.4 | ^8.0",
61+
"symfony/property-info": "^5.4 | ^6.4 | ^7.4 | ^8.0",
62+
"symfony/routing": "^5.4 | ^6.4 | ^7.4 | ^8.0",
63+
"symfony/security-bundle": "^5.4 | ^6.4 | ^7.4 | ^8.0",
64+
"symfony/security-core": "^5.4 | ^6.4 | ^7.4 | ^8.0",
65+
"symfony/security-csrf": "^5.4 | ^6.4 | ^7.4 | ^8.0",
66+
"symfony/security-http": "^5.4 | ^6.4 | ^7.4 | ^8.0",
67+
"symfony/stopwatch": "^5.4 | ^6.4 | ^7.4 | ^8.0",
68+
"symfony/string": "^5.4 | ^6.4 | ^7.4 | ^8.0",
69+
"symfony/translation": "^5.4 | ^6.4 | ^7.4 | ^8.0",
70+
"symfony/twig-bundle": "^5.4 | ^6.4 | ^7.4 | ^8.0",
71+
"symfony/validator": "^5.4 | ^6.4 | ^7.4 | ^8.0",
72+
"symfony/var-dumper": "^5.4 | ^6.4 | ^7.4 | ^8.0",
73+
"symfony/var-exporter": "^5.4 | ^6.4 | ^7.4",
74+
"symfony/yaml": "^5.4 | ^6.4 | ^7.4 | ^8.0",
75+
"vlucas/phpdotenv": "^4.2 | ^5.6"
6676
},
6777
"suggest": {
78+
"codeception/codeception": "Install Codeception to run tests using this module",
6879
"codeception/module-asserts": "Include traditional PHPUnit assertions in your tests",
6980
"symfony/web-profiler-bundle": "Tool that gives information about the execution of requests"
7081
},
@@ -73,6 +84,12 @@
7384
"Codeception\\": "src/Codeception/"
7485
}
7586
},
87+
"autoload-dev": {
88+
"psr-4": {
89+
"Tests\\": "tests",
90+
"Tests\\App\\": "tests/_app"
91+
}
92+
},
7693
"config": {
7794
"sort-packages": true
7895
},

0 commit comments

Comments
 (0)