Skip to content

Commit 5503d65

Browse files
authored
Merge pull request #2934 from teohhanhui/merge-2.4
Merge 2.4 into master
2 parents a62a077 + 81a4f4a commit 5503d65

36 files changed

+344
-184
lines changed

.circleci/config.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ commands:
3939
command: |
4040
sudo pecl install mongodb-1.5.4
4141
sudo docker-php-ext-enable mongodb
42+
install-pcov-php-extension:
43+
steps:
44+
- run:
45+
name: Install pcov PHP extension
46+
command: |
47+
sudo pecl install pcov-1.0.6
48+
sudo docker-php-ext-enable pcov
4249
merge-code-coverage-reports:
4350
parameters:
4451
dir:
@@ -51,14 +58,16 @@ commands:
5158
- run:
5259
name: Download phpcov
5360
command: |
54-
if [ ! -e phpcov.phar ]; then
61+
if ! command -v phpcov; then
5562
wget https://phar.phpunit.de/phpcov.phar
63+
chmod +x phpcov.phar
64+
sudo mv phpcov.phar /usr/local/bin/phpcov
5665
fi
5766
- run:
5867
name: Merge code coverage reports
5968
command: |
6069
mkdir -p "$(dirname -- "<< parameters.out >>")"
61-
phpdbg -qrr phpcov.phar merge --clover "<< parameters.out >>" "<< parameters.dir >>"
70+
phpcov merge --clover "<< parameters.out >>" "<< parameters.dir >>"
6271
merge-test-reports:
6372
parameters:
6473
dir:
@@ -263,6 +272,7 @@ jobs:
263272
steps:
264273
- checkout
265274
- install-mongodb-php-extension
275+
- install-pcov-php-extension
266276
- disable-xdebug-php-extension
267277
- disable-php-memory-limit
268278
- update-composer
@@ -276,7 +286,7 @@ jobs:
276286
mkdir -p build/logs/phpunit build/coverage
277287
split_tests=$(find tests -name '*Test.php' | circleci tests split --split-by=timings)
278288
export PARALLEL='-j10% --joblog build/logs/parallel.log --rpl {_}\ s/\\//_/g;'
279-
phpunit_cmd='phpdbg -qrr vendor/bin/phpunit --coverage-php build/coverage/coverage-{_}.cov --log-junit build/logs/phpunit/{_}.xml --exclude-group mongodb,resource-hog --colors=always {}'
289+
phpunit_cmd='vendor/bin/phpunit --coverage-php build/coverage/coverage-{_}.cov --log-junit build/logs/phpunit/{_}.xml --exclude-group mongodb,resource-hog --colors=always {}'
280290
echo "$split_tests" | parallel "$phpunit_cmd" || echo "$split_tests" | parallel --retry-failed "$phpunit_cmd"
281291
- restore-npm-cache
282292
- merge-test-reports:
@@ -310,6 +320,7 @@ jobs:
310320
steps:
311321
- checkout
312322
- install-mongodb-php-extension
323+
- install-pcov-php-extension
313324
- disable-xdebug-php-extension
314325
- disable-php-memory-limit
315326
- update-composer
@@ -323,7 +334,7 @@ jobs:
323334
mkdir -p build/logs/behat build/coverage
324335
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' -not -path 'features/elasticsearch/*' -not -path 'features/mongodb/*' | circleci tests split --split-by=timings); do
325336
_f=$(echo "$f" | tr / _)
326-
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat/"${_f}" --profile=default-coverage --no-interaction "$f"
337+
FEATURE="${_f}" vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat/"${_f}" --profile=default-coverage --no-interaction "$f"
327338
done
328339
- restore-npm-cache
329340
- merge-test-reports:
@@ -355,6 +366,7 @@ jobs:
355366
steps:
356367
- checkout
357368
- install-mongodb-php-extension
369+
- install-pcov-php-extension
358370
- disable-xdebug-php-extension
359371
- disable-php-memory-limit
360372
- update-composer
@@ -367,7 +379,7 @@ jobs:
367379
name: Run PHPUnit tests
368380
command: |
369381
mkdir -p build/logs/phpunit
370-
phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/phpunit/junit.xml --exclude-group resource-hog --colors=always --configuration phpunit_mongodb.xml
382+
vendor/bin/phpunit --coverage-clover build/logs/clover.xml --log-junit build/logs/phpunit/junit.xml --exclude-group resource-hog --colors=always --configuration phpunit_mongodb.xml
371383
- store_test_results:
372384
path: build/logs
373385
- store_artifacts:
@@ -392,6 +404,7 @@ jobs:
392404
steps:
393405
- checkout
394406
- install-mongodb-php-extension
407+
- install-pcov-php-extension
395408
- disable-xdebug-php-extension
396409
- disable-php-memory-limit
397410
- update-composer
@@ -404,7 +417,7 @@ jobs:
404417
name: Run Behat tests
405418
command: |
406419
mkdir -p build/logs/behat
407-
phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=mongodb-coverage --no-interaction
420+
vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=mongodb-coverage --no-interaction
408421
- restore-npm-cache
409422
- merge-test-reports:
410423
dir: build/logs/behat
@@ -435,6 +448,7 @@ jobs:
435448
steps:
436449
- checkout
437450
- install-mongodb-php-extension
451+
- install-pcov-php-extension
438452
- disable-xdebug-php-extension
439453
- disable-php-memory-limit
440454
- update-composer
@@ -447,7 +461,7 @@ jobs:
447461
name: Run Behat tests
448462
command: |
449463
mkdir -p build/logs/behat
450-
phpdbg -qrr vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=elasticsearch-coverage --no-interaction
464+
vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat --profile=elasticsearch-coverage --no-interaction
451465
- restore-npm-cache
452466
- merge-test-reports:
453467
dir: build/logs/behat

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ jobs:
209209
- *validate-openapi-v3-yaml
210210

211211
- php: '7.3'
212-
env: SYMFONY_DEPRECATIONS_HELPER=max[total]=0
212+
env: SYMFONY_DEPRECATIONS_HELPER=max[total]=5 # 5 deprecation notices from FOSUserBundle
213213
before_install:
214214
- *install-mongodb-php-extension
215215
- *disable-xdebug-php-extension
@@ -229,5 +229,5 @@ jobs:
229229
- *validate-openapi-v3-yaml
230230

231231
allow_failures:
232-
- env: SYMFONY_DEPRECATIONS_HELPER=max[total]=0
232+
- env: SYMFONY_DEPRECATIONS_HELPER=max[total]=5 # 5 deprecation notices from FOSUserBundle
233233
fast_finish: true

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ It natively supports popular open formats including [JSON for Linked Data (JSON-
99
Build a working and fully-featured CRUD API in minutes. Leverage the awesome features of the tool to develop complex and
1010
high performance API-first projects. Extend or override everything you want.
1111

12-
[![Build Status](https://travis-ci.org/api-platform/core.svg?branch=master)](https://travis-ci.org/api-platform/core)
13-
[![Build status](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle)
14-
[![codecov](https://codecov.io/gh/api-platform/core/branch/master/graph/badge.svg)](https://codecov.io/gh/api-platform/core)
12+
[![Travis CI](https://travis-ci.org/api-platform/core.svg?branch=master)](https://travis-ci.org/api-platform/core)
13+
[![CircleCI](https://circleci.com/gh/api-platform/core/tree/master.svg?style=shield)](https://circleci.com/gh/api-platform/core/tree/master)
14+
[![AppVeyor](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l/branch/master?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle/branch/master)
15+
[![Codecov](https://codecov.io/gh/api-platform/core/branch/master/graph/badge.svg)](https://codecov.io/gh/api-platform/core/branch/master)
1516
[![SymfonyInsight](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93/mini.svg)](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93)
1617
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/api-platform/core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/api-platform/core/?branch=master)
1718

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"phpstan/phpstan-doctrine": "^0.11",
5454
"phpstan/phpstan-phpunit": "^0.11",
5555
"phpstan/phpstan-symfony": "^0.11",
56-
"phpunit/phpunit": "^7.5.2 || ^8.0.0",
56+
"phpunit/phpunit": "^7.5.2 || ^8.0",
5757
"psr/log": "^1.0",
5858
"ramsey/uuid": "^3.7",
5959
"ramsey/uuid-doctrine": "^1.4",

features/bootstrap/DoctrineContext.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,8 +1454,10 @@ public function thereIsTheFollowingProduct(PyStringNode $dataNode): void
14541454
$product = $this->isOrm() ? new Product() : new ProductDocument();
14551455
$product->setCode($data['code']);
14561456
if (isset($data['mainTaxon'])) {
1457-
$mainTaxonId = (int) str_replace('/taxons/', '', $data['mainTaxon']);
1458-
$mainTaxon = $this->manager->getRepository($this->isOrm() ? Taxon::class : TaxonDocument::class)->find($mainTaxonId);
1457+
$mainTaxonCode = str_replace('/taxons/', '', $data['mainTaxon']);
1458+
$mainTaxon = $this->manager->getRepository($this->isOrm() ? Taxon::class : TaxonDocument::class)->findOneBy([
1459+
'code' => $mainTaxonCode,
1460+
]);
14591461
$product->setMainTaxon($mainTaxon);
14601462
}
14611463
$this->manager->persist($product);

features/json/input_output.feature

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Feature: JSON DTO input and output
2+
In order to use the API
3+
As a client software developer
4+
I need to be able to use DTOs on my resources as Input or Output objects.
5+
6+
Background:
7+
Given I add "Accept" header equal to "application/json"
8+
And I add "Content-Type" header equal to "application/json"
9+
10+
Scenario: Request a password reset
11+
And I send a "POST" request to "/users/password_reset_request" with body:
12+
"""
13+
{
14+
"email": "[email protected]"
15+
}
16+
"""
17+
Then the response status code should be 201
18+
And the response should be in JSON
19+
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
20+
And the JSON should be equal to:
21+
"""
22+
{
23+
"emailSentAt": "2019-07-05T15:44:00+00:00"
24+
}
25+
"""
26+
27+
Scenario: Request a password reset for a non-existent user
28+
And I send a "POST" request to "/users/password_reset_request" with body:
29+
"""
30+
{
31+
"email": "[email protected]"
32+
}
33+
"""
34+
Then the response status code should be 404
35+
And the response should be in JSON
36+
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
37+
And the JSON node "detail" should be equal to "User does not exist."

features/jsonld/interface_as_resource.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ Feature: JSON-LD using interface as resource
1515
"code": "WONDERFUL_TAXON"
1616
}
1717
"""
18-
When I send a "GET" request to "/taxons/1"
18+
When I send a "GET" request to "/taxons/WONDERFUL_TAXON"
1919
Then the response status code should be 200
2020
And the response should be in JSON
2121
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
2222
And the JSON should be equal to:
2323
"""
2424
{
2525
"@context": "/contexts/Taxon",
26-
"@id": "/taxons/1",
26+
"@id": "/taxons/WONDERFUL_TAXON",
2727
"@type": "Taxon",
2828
"code": "WONDERFUL_TAXON"
2929
}
@@ -34,22 +34,22 @@ Feature: JSON-LD using interface as resource
3434
"""
3535
{
3636
"code": "GREAT_PRODUCT",
37-
"mainTaxon": "/taxons/1"
37+
"mainTaxon": "/taxons/WONDERFUL_TAXON"
3838
}
3939
"""
40-
When I send a "GET" request to "/products/1"
40+
When I send a "GET" request to "/products/GREAT_PRODUCT"
4141
Then the response status code should be 200
4242
And the response should be in JSON
4343
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
4444
And the JSON should be equal to:
4545
"""
4646
{
4747
"@context": "/contexts/Product",
48-
"@id": "/products/1",
48+
"@id": "/products/GREAT_PRODUCT",
4949
"@type": "Product",
5050
"code": "GREAT_PRODUCT",
5151
"mainTaxon": {
52-
"@id": "/taxons/1",
52+
"@id": "/taxons/WONDERFUL_TAXON",
5353
"@type": "Taxon",
5454
"code": "WONDERFUL_TAXON"
5555
}

phpstan.neon.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ parameters:
6868
-
6969
message: '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util\\QueryBuilderHelper::mapJoinAliases() should return array<string, array<string>\|string> but returns array<int|string, mixed>\.#'
7070
path: %currentWorkingDirectory%/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php
71+
# https://github.com/phpstan/phpstan/issues/1482
7172
-
72-
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and '(removeBindings|addRemovedBindingIds)' will always evaluate to false\\.#"
73+
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'removeBindings' will always evaluate to false\\.#"
7374
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php
7475
-
7576
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getReachableRoleNam.+' will always evaluate to false\\.#"
@@ -78,7 +79,7 @@ parameters:
7879
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getRoleNames' will always evaluate to false\\.#"
7980
path: %currentWorkingDirectory%/tests/Security/EventListener/DenyAccessListenerTest.php
8081
- "#Call to method PHPUnit\\\\Framework\\\\Assert::assertSame\\(\\) with array\\('(collection_context|item_context|subresource_context)'\\) and array<Symfony\\\\Component\\\\VarDumper\\\\Cloner\\\\Data>\\|bool\\|float\\|int\\|string\\|null will always evaluate to false\\.#"
81-
# https://github.com/doctrine/doctrine2/pull/7298/files
82+
# https://github.com/doctrine/doctrine2/pull/7298
8283
- '#Strict comparison using === between null and int will always evaluate to false\.#'
8384
-
8485
message: '#Binary operation "\+" between (float\|int\|)?string and 0 results in an error\.#'

src/Bridge/Symfony/Bundle/Resources/config/api.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@
175175

176176
<service id="api_platform.listener.view.write" class="ApiPlatform\Core\EventListener\WriteListener">
177177
<argument type="service" id="api_platform.data_persister" />
178-
<argument type="service" id="api_platform.iri_converter" on-invalid="null" />
178+
<argument type="service" id="api_platform.iri_converter" />
179179
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
180+
<argument type="service" id="api_platform.resource_class_resolver" />
180181

181182
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" priority="32" />
182183
</service>

src/Bridge/Symfony/Messenger/DataPersister.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public function persist($data, array $context = [])
8888
*/
8989
public function remove($data, array $context = [])
9090
{
91-
$this->messageBus->dispatch(new Envelope($data, [new RemoveStamp()]));
91+
$this->messageBus->dispatch(
92+
(new Envelope($data))
93+
->with(new RemoveStamp())
94+
);
9295
}
9396
}

0 commit comments

Comments
 (0)