Skip to content

Commit c4d2c53

Browse files
committed
ci: upgrade to phpunit 12
Remove soyuka/phpunit fork from all composer.json files and upgrade to PHPUnit 12.2. Update CI workflow to install PHPUnit before other steps and configure MongoDB conditional execution. Migrate tests from Prophecy to PHPUnit native mocking in FieldsBuilderTest and Symfony event listener tests. Remove unused dataprovider and fix warnings.
1 parent 7c9ae82 commit c4d2c53

36 files changed

+1203
-247
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
composer global require soyuka/pmu
4949
composer global config allow-plugins.soyuka/pmu true --no-interaction
5050
composer global link .
51+
composer require --dev doctrine/mongodb-odm-bundle
5152
- run: composer check-dependencies
5253

5354
php-cs-fixer:
@@ -89,7 +90,7 @@ jobs:
8990
uses: shivammathur/setup-php@v2
9091
with:
9192
php-version: ${{ matrix.php }}
92-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
93+
extensions: intl, bcmath, curl, openssl, mbstring
9394
ini-values: memory_limit=-1
9495
tools: composer
9596
coverage: none
@@ -149,6 +150,7 @@ jobs:
149150
composer global require soyuka/pmu
150151
composer global config allow-plugins.soyuka/pmu true --no-interaction
151152
composer global link .
153+
composer require --dev doctrine/mongodb-odm-bundle
152154
- name: Cache PHPStan results
153155
uses: actions/cache@v4
154156
with:
@@ -200,7 +202,7 @@ jobs:
200202
with:
201203
php-version: ${{ matrix.php }}
202204
tools: pecl, composer
203-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
205+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
204206
coverage: pcov
205207
ini-values: memory_limit=-1
206208
- name: Get composer cache directory
@@ -217,6 +219,9 @@ jobs:
217219
composer global require soyuka/pmu
218220
composer global config allow-plugins.soyuka/pmu true --no-interaction
219221
composer global link .
222+
- name: Force PHPUnit 11.5 for PHP 8.2
223+
if: matrix.php == '8.2'
224+
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
220225
- name: Clear test app cache
221226
run: tests/Fixtures/app/console cache:clear --ansi
222227
- name: Run PHPUnit tests
@@ -288,12 +293,17 @@ jobs:
288293
with:
289294
php-version: ${{ matrix.php.version }}
290295
tools: pecl, composer
291-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
296+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
292297
ini-values: memory_limit=-1
293298
- name: PMU
294299
run: |
295300
composer global require soyuka/pmu
296301
composer global config allow-plugins.soyuka/pmu true --no-interaction
302+
- name: Force PHPUnit 11.5 for PHP 8.2
303+
if: matrix.php.version == '8.2'
304+
run: |
305+
cd $(composer ${{matrix.component}} --cwd)
306+
composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
297307
- name: Linking
298308
if: ${{ !matrix.php.lowest && !matrix.php.minimal-changes }}
299309
run: |
@@ -368,7 +378,7 @@ jobs:
368378
with:
369379
php-version: ${{ matrix.php.version }}
370380
tools: pecl, composer
371-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
381+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
372382
ini-values: memory_limit=-1
373383
- name: Linking
374384
run: |
@@ -408,7 +418,7 @@ jobs:
408418
with:
409419
php-version: ${{ matrix.php }}
410420
tools: pecl, composer
411-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
421+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
412422
coverage: pcov
413423
ini-values: memory_limit=-1
414424
- name: Get composer cache directory
@@ -425,6 +435,9 @@ jobs:
425435
composer global require soyuka/pmu
426436
composer global config allow-plugins.soyuka/pmu true --no-interaction
427437
composer global link .
438+
- name: Force PHPUnit 11.5 for PHP 8.2
439+
if: matrix.php == '8.2'
440+
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
428441
- name: Clear test app cache
429442
run: tests/Fixtures/app/console cache:clear --ansi
430443
- name: Run Behat tests (PHP ${{ matrix.php }})
@@ -492,7 +505,7 @@ jobs:
492505
with:
493506
php-version: ${{ matrix.php }}
494507
tools: pecl, composer
495-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql, mongodb
508+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_pgsql
496509
coverage: none
497510
ini-values: memory_limit=-1
498511
- name: Get composer cache directory
@@ -543,7 +556,7 @@ jobs:
543556
with:
544557
php-version: ${{ matrix.php }}
545558
tools: pecl, composer
546-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql, mongodb
559+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_mysql
547560
coverage: none
548561
ini-values: memory_limit=-1
549562
- name: Get composer cache directory
@@ -825,7 +838,7 @@ jobs:
825838
with:
826839
php-version: ${{ matrix.php }}
827840
tools: pecl, composer
828-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
841+
extensions: intl, bcmath, curl, openssl, mbstring
829842
coverage: none
830843
ini-values: memory_limit=-1
831844
- name: Get composer cache directory
@@ -878,7 +891,7 @@ jobs:
878891
with:
879892
php-version: ${{ matrix.php }}
880893
tools: pecl, composer
881-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
894+
extensions: intl, bcmath, curl, openssl, mbstring
882895
coverage: none
883896
ini-values: memory_limit=-1
884897
- name: Get composer cache directory
@@ -918,7 +931,7 @@ jobs:
918931
with:
919932
php-version: ${{ matrix.php }}
920933
tools: pecl, composer
921-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
934+
extensions: intl, bcmath, curl, openssl, mbstring
922935
coverage: none
923936
ini-values: memory_limit=-1
924937
- name: Get composer cache directory
@@ -957,7 +970,7 @@ jobs:
957970
with:
958971
php-version: ${{ matrix.php }}
959972
tools: pecl, composer
960-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
973+
extensions: intl, bcmath, curl, openssl, mbstring
961974
coverage: none
962975
ini-values: memory_limit=-1
963976
- name: Get composer cache directory
@@ -1000,7 +1013,7 @@ jobs:
10001013
with:
10011014
php-version: ${{ matrix.php }}
10021015
tools: pecl, composer
1003-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
1016+
extensions: intl, bcmath, curl, openssl, mbstring
10041017
coverage: none
10051018
ini-values: memory_limit=-1
10061019
- name: Install additional packages
@@ -1048,7 +1061,7 @@ jobs:
10481061
with:
10491062
php-version: ${{ matrix.php }}
10501063
tools: pecl, composer
1051-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo, mongodb
1064+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, fileinfo
10521065
coverage: none
10531066
ini-values: memory_limit=-1
10541067
- name: Get composer cache directory
@@ -1098,7 +1111,7 @@ jobs:
10981111
with:
10991112
php-version: ${{ matrix.php }}
11001113
tools: pecl, composer
1101-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
1114+
extensions: intl, bcmath, curl, openssl, mbstring
11021115
coverage: none
11031116
ini-values: memory_limit=-1
11041117
- name: Get composer cache directory
@@ -1142,7 +1155,7 @@ jobs:
11421155
with:
11431156
php-version: ${{ matrix.php }}
11441157
tools: pecl, composer
1145-
extensions: intl, bcmath, curl, openssl, mbstring, mongodb
1158+
extensions: intl, bcmath, curl, openssl, mbstring
11461159
coverage: none
11471160
ini-values: memory_limit=-1
11481161
- name: Install additional packages
@@ -1314,7 +1327,7 @@ jobs:
13141327
with:
13151328
php-version: ${{ matrix.php }}
13161329
tools: pecl, composer
1317-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
1330+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
13181331
ini-values: memory_limit=-1
13191332
- name: Setup node
13201333
uses: actions/setup-node@v4
@@ -1369,8 +1382,12 @@ jobs:
13691382
with:
13701383
php-version: ${{ matrix.php }}
13711384
tools: pecl, composer
1372-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
1385+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
13731386
ini-values: memory_limit=-1
1387+
- name: Force PHPUnit 11.5 for PHP 8.2
1388+
if: matrix.php == '8.2'
1389+
working-directory: 'src/Laravel'
1390+
run: composer require phpunit/phpunit:^11.5 --dev --with-all-dependencies
13741391
- name: Update project dependencies
13751392
run: |
13761393
composer global require soyuka/pmu
@@ -1395,7 +1412,7 @@ jobs:
13951412
with:
13961413
php-version: 8.4
13971414
tools: pecl, composer
1398-
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite, mongodb
1415+
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
13991416
ini-values: memory_limit=-1
14001417
- name: Update project dependencies
14011418
run: |

CRUSH.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# API Platform Core Development
2+
3+
This document provides guidelines for developing on the API Platform core.
4+
5+
## Laravel development:
6+
7+
Everything goes inside `src/Laravel`.
8+
Tests need to run at `src/Laravel/vendor/bin/phpunit`.
9+
10+
## Development Commands
11+
12+
- **Run all tests:**
13+
```bash
14+
vendor/bin/phpunit
15+
```
16+
17+
- **Run a single test file:**
18+
```bash
19+
vendor/bin/phpunit tests/Path/To/YourTest.php
20+
```
21+
22+
- **Lint files:**
23+
```bash
24+
vendor/bin/php-cs-fixer fix --dry-run --diff
25+
```
26+
27+
- **Fix linting issues:**
28+
```bash
29+
vendor/bin/php-cs-fixer fix
30+
```
31+
32+
- **Run static analysis:**
33+
```bash
34+
vendor/bin/phpstan analyse
35+
```
36+
37+
## Code Style
38+
39+
- **Standard:** Follow PSR-12 and the rules in `.php-cs-fixer.dist.php`.
40+
- **Imports:** Use `use` statements for all classes, and group them by namespace.
41+
- **Naming:**
42+
- Classes: `PascalCase`
43+
- Methods: `camelCase`
44+
- Variables: `camelCase`
45+
- **Types:** Use strict types (`declare(strict_types=1);`) in all PHP files. Use type hints for all arguments and return types where possible.
46+
- **Error Handling:** Use exceptions for error handling.
47+

Caddyfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# To run this make sure you have php zts installed
2+
# In the `php.ini` set output_buffering = Off (or else you may not get the same measures)
3+
# Run `php-fpm -F` (it should default to 127.0.0.1:9000)
4+
# Run `frankenphp start --config Caddyfile` (do not use `run` or printing in the terminal will slow down the server)
5+
# You now have 2 servers:
6+
# - localhost:8080 with PHP FPM
7+
# - localhost:8081 with FrankenPHP
8+
#
9+
# Note that with no worker mode the performances on HTTP Request (sequentially !) will be likely the same.
10+
{
11+
frankenphp
12+
}
13+
14+
localhost:8080 {
15+
header {
16+
Access-Control-Allow-Origin *
17+
Access-Control-Allow-Credentials true
18+
Access-Control-Allow-Methods *
19+
Access-Control-Allow-Headers *
20+
defer
21+
}
22+
root * public/
23+
php_fastcgi 127.0.0.1:9000
24+
file_server
25+
}
26+
27+
localhost:8081 {
28+
header {
29+
Access-Control-Allow-Origin *
30+
Access-Control-Allow-Credentials true
31+
Access-Control-Allow-Methods *
32+
Access-Control-Allow-Headers *
33+
defer
34+
}
35+
root * public/
36+
file_server
37+
log
38+
php_server
39+
}

GEMINI.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
You are a code assistant that only writes tests on the API Platform code base. You do not need to fix bugs only write the test we ask for. You do not need to run the test.
2+
3+
Language is PHP, project is API Platform. User will always specify either Symfony or Laravel as tests are not in the same directories.
4+
5+
IMPORTANT: avoid changing existing fixtures as they may alter current tests behavior. If a fixture already exist just invent new names, we don't really care about business logic here we only do tests for a framework.
6+
7+
# API Platform Core Development
8+
9+
This document provides guidelines for developing on the API Platform core.
10+
11+
## Laravel development:
12+
13+
Everything goes inside `src/Laravel`.
14+
Tests need to run at `src/Laravel/vendor/bin/phpunit`.
15+
Fixtures are located at `src/Laravel/workbench/app/` you can either write a DTO as ApiResource inside the `ApiResource` directory in the workbench, or add an Eloquent `Model` that gets declared as a resource with the correct attribute.
16+
17+
You'll add only functional testing inside `src/Laravel/Tests/`, we recommend to inspire from @src/Laravel/Tests/EloquentTest.php or @src/Laravel/Tests/JsonLdTest.php.
18+
19+
## Symfony development:
20+
21+
Fixtures are located at `tests/Fixtures/TestBundle/ApiResource/`
22+
Entities at `tests/Fixtures/TestBundle/Entity/` and they almost always see their equivalent in `tests/Fixtures/TestBundle/Document/`
23+
Functional tests at `tests/Functional`, unit tests are in more specific directories of each component inside `src/Component/Tests`.
24+
25+
## Development Commands
26+
27+
You can not run command only the user can. Don't attempt to run phpunit or else.
28+
29+
## Code Style
30+
31+
- **Standard:** Follow PSR-12 and the rules in `.php-cs-fixer.dist.php`.
32+
- **Imports:** Use `use` statements for all classes, and group them by namespace.
33+
- **Naming:**
34+
- Classes: `PascalCase`
35+
- Methods: `camelCase`
36+
- Variables: `camelCase`
37+
- **Types:** Use strict types (`declare(strict_types=1);`) in all PHP files. Use type hints for all arguments and return types where possible.
38+
- **Error Handling:** Use exceptions for error handling.

composer.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,11 @@
123123
"willdurand/negotiation": "^3.1"
124124
},
125125
"require-dev": {
126-
"ext-mongodb": "^1.21 || ^2.0",
127126
"behat/behat": "^3.11",
128127
"behat/mink": "^1.9",
129-
"doctrine/cache": "^1.11 || ^2.1",
130128
"doctrine/common": "^3.2.2",
131129
"doctrine/dbal": "^4.0",
132130
"doctrine/doctrine-bundle": "^2.11 || ^3.1",
133-
"doctrine/mongodb-odm": "^2.10",
134-
"doctrine/mongodb-odm-bundle": "^5.0",
135131
"doctrine/orm": "^2.17 || ^3.0",
136132
"elasticsearch/elasticsearch": "^7.17 || ^8.4 || ^9.0",
137133
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
@@ -156,7 +152,7 @@
156152
"phpstan/phpstan-doctrine": "^2.0",
157153
"phpstan/phpstan-phpunit": "^2.0",
158154
"phpstan/phpstan-symfony": "^2.0",
159-
"phpunit/phpunit": "11.5.x-dev",
155+
"phpunit/phpunit": "^12.2",
160156
"psr/log": "^1.0 || ^2.0 || ^3.0",
161157
"ramsey/uuid": "^4.7",
162158
"ramsey/uuid-doctrine": "^2.0",
@@ -216,8 +212,5 @@
216212
"symfony/json-streamer": "To use the JSON Streamer component.",
217213
"webonyx/graphql-php": "To support GraphQL."
218214
},
219-
"type": "library",
220-
"repositories": [
221-
{"type": "vcs", "url": "https://github.com/soyuka/phpunit"}
222-
]
215+
"type": "library"
223216
}

0 commit comments

Comments
 (0)