Skip to content

Commit

Permalink
[Unit][Orders] Add test for changing item quantity of the cart
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafikooo committed Jul 3, 2023
1 parent a6df3c9 commit aafc207
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Api/Shop/OrdersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,29 @@ public function it_prevents_from_adding_an_item_to_the_cart_if_quantity_is_missi

$this->assertResponseCode($response, Response::HTTP_UNPROCESSABLE_ENTITY);
}

/** @test */
public function it_prevents_from_changing_an_item_quantity_if_quantity_is_missing(): 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);

$this->client->request(
method: 'PATCH',
uri: sprintf('/api/v2/shop/orders/%s/items/%s', $tokenValue, 1),
server: self::PATCH_CONTENT_TYPE_HEADER,
content: json_encode([]),
);
$response = $this->client->getResponse();

$this->assertResponseCode($response, Response::HTTP_UNPROCESSABLE_ENTITY);
}
}

0 comments on commit aafc207

Please sign in to comment.