diff --git a/src/Component/Metadata/Api/ApiOperationInterface.php b/src/Component/Metadata/Api/ApiOperationInterface.php new file mode 100644 index 000000000..61fa8f2c4 --- /dev/null +++ b/src/Component/Metadata/Api/ApiOperationInterface.php @@ -0,0 +1,21 @@ +getResource()?->getIdentifier() ?? 'id'; if ($operation instanceof DeleteOperationInterface) { - $path = match ($shortName) { - 'delete' => '', - default => '/' . $shortName, - }; + $path = $operation instanceof ApiOperationInterface && 'delete' === $shortName ? '' : '/' . $shortName; return sprintf('%s/{%s}%s', $rootPath, $identifier, $path); } diff --git a/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php index 7061c6880..ed5599857 100644 --- a/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php @@ -36,14 +36,14 @@ function it_generates_route_path_for_delete_operations(): void { $operation = new Delete(); - $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{id}'); + $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{id}/delete'); } function it_generates_route_path_for_delete_operations_with_custom_identifier(): void { $operation = (new Delete())->withResource(new Resource(identifier: 'code')); - $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{code}'); + $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{code}/delete'); } function it_generates_route_path_for_update_operations_with_custom_short_name(): void @@ -59,4 +59,11 @@ function it_generates_route_path_for_api_delete_operations(): void $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{id}'); } + + function it_generates_route_path_for_api_delete_operations_with_custom_short_name(): void + { + $operation = new Api\Delete(shortName: 'remove'); + + $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{id}/remove'); + } } diff --git a/tests/Application/src/Subscription/Entity/Subscription.php b/tests/Application/src/Subscription/Entity/Subscription.php index 0d68249a9..7f9d6b8c7 100644 --- a/tests/Application/src/Subscription/Entity/Subscription.php +++ b/tests/Application/src/Subscription/Entity/Subscription.php @@ -39,6 +39,7 @@ #[Index(grid: 'app_subscription')] #[Create] #[Update] +#[Delete] #[BulkDelete] #[ApplyStateMachineTransition(stateMachineTransition: 'accept')] #[ApplyStateMachineTransition(stateMachineTransition: 'reject')] @@ -46,7 +47,6 @@ shortName: 'bulk_accept', stateMachineTransition: 'accept', )] -#[Delete] #[Show( template: 'subscription/show.html.twig', twigContextFactory: ShowSubscriptionContextFactory::class, diff --git a/tests/Application/src/Tests/Controller/BoardGameUiTest.php b/tests/Application/src/Tests/Controller/BoardGameUiTest.php index 354c80d1d..29fe7ed2e 100644 --- a/tests/Application/src/Tests/Controller/BoardGameUiTest.php +++ b/tests/Application/src/Tests/Controller/BoardGameUiTest.php @@ -50,12 +50,12 @@ public function it_allows_browsing_board_games(): void $this->assertStringContainsString('