From 3fb723123acba37fe7ebdb5832ce0493836917ed Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Fri, 24 May 2024 17:59:06 +0200 Subject: [PATCH] test: PATCH on controller w/ dto (#6368) * test: PATCH on controller w/ dto * ci: allow uppercase commit message start --- .commitlintrc | 3 +-- behat.yml.dist | 2 +- features/main/patch.feature | 8 +++++++- .../Issue6355/UpdateOrderProductCountController.php | 4 +--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.commitlintrc b/.commitlintrc index 6e77094ed54..9980f3e6228 100644 --- a/.commitlintrc +++ b/.commitlintrc @@ -55,8 +55,7 @@ [ "sentence-case", "start-case", - "pascal-case", - "upper-case" + "pascal-case" ] ], "subject-empty": [ diff --git a/behat.yml.dist b/behat.yml.dist index 4a6d7330aff..887ae86f758 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -203,7 +203,7 @@ legacy: - 'Behat\MinkExtension\Context\MinkContext' - 'behatch:context:rest' filters: - tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@link_security' + tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@link_security&&~@use_listener' extensions: 'FriendsOfBehat\SymfonyExtension': bootstrap: 'tests/Fixtures/app/bootstrap.php' diff --git a/features/main/patch.feature b/features/main/patch.feature index 96ce6653fde..d6be7ec5437 100644 --- a/features/main/patch.feature +++ b/features/main/patch.feature @@ -81,6 +81,10 @@ Feature: Sending PATCH requets } """ + @use_listener + @controller + # Previously to 3.3 it was not possible to disable a read, this test is ignored on the + # legacy test suite (EVENT_LISTENERS_BACKWARD_COMPATIBILITY_LAYER=1) Scenario: Patch a non-readable resource When I add "Content-Type" header equal to "application/merge-patch+json" And I send a "PATCH" request to "/order_products/1/count" with body: @@ -89,5 +93,7 @@ Feature: Sending PATCH requets "id": 1, "count": 10 } + """ - Then print last JSON response + Then the response status code should be 200 + And the JSON node "id" should contain "1" diff --git a/tests/Fixtures/TestBundle/Controller/Issue6355/UpdateOrderProductCountController.php b/tests/Fixtures/TestBundle/Controller/Issue6355/UpdateOrderProductCountController.php index 1f96f0390dd..38c7cbc0f11 100644 --- a/tests/Fixtures/TestBundle/Controller/Issue6355/UpdateOrderProductCountController.php +++ b/tests/Fixtures/TestBundle/Controller/Issue6355/UpdateOrderProductCountController.php @@ -14,15 +14,13 @@ namespace ApiPlatform\Tests\Fixtures\TestBundle\Controller\Issue6355; use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6355\OrderDto; -use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6355\OrderProductCount; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Attribute\AsController; #[AsController] class UpdateOrderProductCountController extends AbstractController { - public function __invoke(OrderProductCount $data, Request $request): OrderDto + public function __invoke(): OrderDto { $dto = new OrderDto(); $dto->id = 1;