Skip to content

Commit

Permalink
test: PATCH on controller w/ dto (#6368)
Browse files Browse the repository at this point in the history
* test: PATCH on controller w/ dto

* ci: allow uppercase commit message start
  • Loading branch information
soyuka committed May 24, 2024
1 parent 77a917f commit 3fb7231
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .commitlintrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
[
"sentence-case",
"start-case",
"pascal-case",
"upper-case"
"pascal-case"
]
],
"subject-empty": [
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 7 additions & 1 deletion features/main/patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3fb7231

Please sign in to comment.