Merge branch '1.12' into 1.13

* 1.12:
  [Orders][API] Change cart item delete HTTP response code to 204
This commit is contained in:
Grzegorz Sadowski 2023-02-21 13:56:43 +01:00
commit e1a08fa3d7
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
2 changed files with 27 additions and 1 deletions

View file

@ -34,6 +34,6 @@ final class DeleteOrderItemAction
$this->commandBus->dispatch($command);
return new JsonResponse();
return new JsonResponse(status: Response::HTTP_NO_CONTENT);
}
}

View file

@ -393,4 +393,30 @@ final class OrdersTest extends JsonApiTestCase
$this->assertResponse($response, 'shop/updated_billing_address_on_order_response', Response::HTTP_OK);
}
/** @test */
public function it_removes_item_from_the_cart(): void
{
$this->loadFixturesFromFiles(['channel.yaml', 'cart.yaml']);
$tokenValue = 'nAWw2jewpA';
/** @var MessageBusInterface $commandBus */
$commandBus = self::getContainer()->get('sylius.command_bus');
$pickupCartCommand = new PickupCart($tokenValue);
$pickupCartCommand->setChannelCode('WEB');
$commandBus->dispatch($pickupCartCommand);
$addItemToCartCommand = new AddItemToCart('MUG_BLUE', 3);
$addItemToCartCommand->setOrderTokenValue($tokenValue);
$commandBus->dispatch($addItemToCartCommand);
$this->client->request('GET', sprintf('/api/v2/shop/orders/%s', $tokenValue));
$itemId = json_decode($this->client->getResponse()->getContent(), true)['items'][0]['id'];
$this->client->request('DELETE', sprintf('/api/v2/shop/orders/%s/items/%s', $tokenValue, $itemId));
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_NO_CONTENT);
}
}