Skip to content

Commit

Permalink
feature #12661 [API] Add itemsTotal field to order resource (arti0090)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.10-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master 
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| License         | MIT
![Zrzut ekranu 2021-05-21 o 12 35 53](https://user-images.githubusercontent.com/35863747/119124555-172e3480-ba31-11eb-8a7e-1f7115d8feee.png)


Commits
-------

3f9d64c [API] Add itemsTotal field to order resource
41cca0a Changes to scenarios
0e88a33 Changes to scenario and serialization
f41bf84 Fixes related to missing serialization group
  • Loading branch information
GSadee committed May 24, 2021
2 parents 33731fc + f41bf84 commit 1cc07c5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@shopping_cart
Feature: Seeing detailed information of cart
In order to know more about status of my cart
As a Visitor
I want to be able to see detailed information of my cart

Background:
Given the store operates on a single channel in "United States"
And the store has a product "T-shirt banana" priced at "$12.54"

@api
Scenario: Viewing items of my cart
When I add 5 of them to my cart
And I check items in my cart
Then my cart should have quantity of 5 items of product "T-shirt banana"

@api
Scenario: Viewing items total of my cart
When I add 5 of them to my cart
And I check details of my cart
Then my cart should have "$62.70" items total
15 changes: 0 additions & 15 deletions features/cart/shopping_cart/seeing_order_items_in_cart.feature

This file was deleted.

12 changes: 12 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,20 @@ public function iCheckItemsOfMyCart(string $tokenValue): void
$this->cartsClient->executeCustomRequest($request);
}

/**
* @Then /^my cart should have ("[^"]+") items total$/
*/
public function myCartShouldHaveItemsTotal(int $itemsTotal): void
{
Assert::same(
$this->responseChecker->getValue($this->cartsClient->getLastResponse(), 'itemsTotal'),
$itemsTotal
);
}

/**
* @Then /^my cart should have (\d+) items of (product "([^"]+)")$/
* @Then /^my cart should have quantity of (\d+) items of (product "([^"]+)")$/
*/
public function myCartShouldHaveItems(int $quantity, ProductInterface $product): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/OrderContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function iShouldHaveChosenPaymentMethodForMyOrder(PaymentMethodInterface
->getValue($this->client->show($this->sharedStorage->get('cart_token')), 'payments')[0]
;

Assert::same($this->iriConverter->getIriFromItem($paymentMethod), $payment['method']);
Assert::same($this->iriConverter->getIriFromItem($paymentMethod), $payment['method']['@id']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<itemOperation name="shop_get">
<attribute name="method">GET</attribute>
<attribute name="path">/shop/orders/{tokenValue}</attribute>
<attribute name="normalization_context">
<attribute name="groups">shop:cart:read</attribute>
</attribute>
</itemOperation>

<itemOperation name="shop_delete">
Expand All @@ -70,6 +73,9 @@
<attribute name="openapi_context">
<attribute name="summary">Deletes cart</attribute>
</attribute>
<attribute name="normalization_context">
<attribute name="groups">shop:order:read</attribute>
</attribute>
</itemOperation>

<itemOperation name="admin_cancel">
Expand Down Expand Up @@ -410,6 +416,7 @@
<subresource resourceClass="%sylius.model.order_item.class%" />
</property>
<property name="notes" writable="true" />
<property name="itemsTotal" readable="true" />
<property name="taxTotal" readable="true"/>
<property name="adjustments" writable="false">
<subresource resourceClass="%sylius.model.adjustment.class%" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@

<attribute name="paymentState">
<group>admin:order:read</group>
<group>shop:cart:read</group>
</attribute>

<attribute name="shippingState">
<group>admin:order:read</group>
<group>shop:cart:read</group>
</attribute>

<attribute name="total">
Expand Down Expand Up @@ -102,6 +104,12 @@
<group>admin:order:read</group>
</attribute>

<attribute name="itemsTotal">
<group>shop:cart:read</group>
<group>shop:order:read</group>
<group>shop:order:account:read</group>
</attribute>

<attribute name="taxTotal">
<group>admin:order:read</group>
<group>shop:cart:read</group>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<attribute name="subtotal">
<group>admin:order:read</group>
<group>admin:order_item:read</group>
<group>shop:cart:read</group>
<group>shop:order_item:read</group>
</attribute>
<attribute name="total">
Expand Down

0 comments on commit 1cc07c5

Please sign in to comment.