Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Api][Shop][Order][Address] Viewing order #11888

Merged
merged 3 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Feature: Viewing details of an order
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
And I chose "Free" shipping method with "Cash on Delivery" payment

@ui
@ui @api
Scenario: Viewing basic information about an order
When I view the summary of the order "#00000666"
And it should has number "#00000666"
When I view the summary of my order "#00000666"
Then it should have the number "#00000666"
And I should see "Lucifer Morningstar", "Seaside Fwy", "90802", "Los Angeles", "United States" as shipping address
And I should see "Mazikeen Lilim", "Pacific Coast Hwy", "90806", "Los Angeles", "United States" as billing address
And I should see "$39.00" as order's total
49 changes: 49 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/OrderContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\Converter\AdminToShopIriConverterInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Addressing\Model\CountryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\PromotionInterface;
use Sylius\Component\Core\OrderCheckoutStates;
Expand Down Expand Up @@ -63,6 +65,14 @@ public function __construct(
$this->sharedStorage = $sharedStorage;
}

/**
* @When I view the summary of my order :order
*/
public function iViewTheSummaryOfMyOrder(OrderInterface $order): void
{
$this->client->show($order->getTokenValue());
}

/**
* @Then I should be able to access this order's details
*/
Expand All @@ -81,6 +91,45 @@ public function iShouldBeAbleToAccessThisOrderDetails(): void
);
}

/**
* @Then it should have the number :orderNumber
*/
public function itShouldHaveTheNumber(string $orderNumber): void
{
Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'number'), $orderNumber);
}

/**
* @Then I should see :customerName, :street, :postcode, :city, :country as :addressType address
*/
public function iShouldSeeAsShippingAddress(
string $customerName,
string $street,
string $postcode,
string $city,
CountryInterface $country,
string $addressType
): void {
$address = $this->responseChecker->getValue($this->client->getLastResponse(), ($addressType . 'Address'));

$names = explode(' ', $customerName);

Assert::same($address['firstName'], $names[0]);
Assert::same($address['lastName'], $names[1]);
Assert::same($address['street'], $street);
Assert::same($address['postcode'], $postcode);
Assert::same($address['city'], $city);
Assert::same($address['countryCode'], $country->getCode());
}

/**
* @Then /^I should see ("[^"]+") as order's total$/
*/
public function iShouldSeeAsOrderSTotal(int $total): void
{
Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'total'), $total);
}

/**
* @Then :promotionName should be applied to my order
* @Then :promotionName should be applied to my order shipping
Expand Down
6 changes: 4 additions & 2 deletions src/Sylius/Behat/Context/Ui/Shop/AccountContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ public function thisOrderShouldHaveNumber(OrderInterface $order)

/**
* @When I view the summary of the order :order
* @When I view the summary of my order :order
*/
public function iViewTheSummaryOfTheOrder(OrderInterface $order)
public function iViewTheSummaryOfTheOrder(OrderInterface $order): void
{
$this->orderShowPage->open(['number' => $order->getNumber()]);
}
Expand All @@ -297,8 +298,9 @@ public function iViewingTheSummaryOfMyLastOrder()

/**
* @Then it should has number :orderNumber
* @Then it should have the number :orderNumber
*/
public function itShouldHasNumber($orderNumber)
public function itShouldHasNumber(string $orderNumber): void
{
Assert::same($this->orderShowPage->getNumber(), $orderNumber);
}
Expand Down
11 changes: 11 additions & 0 deletions src/Sylius/Behat/Resources/config/suites/api/account/customer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@ default:
contexts:
- sylius.behat.context.hook.doctrine_orm

- sylius.behat.context.transform.address
- sylius.behat.context.transform.country
- sylius.behat.context.transform.customer
- sylius.behat.context.transform.lexical
- sylius.behat.context.transform.order
- sylius.behat.context.transform.payment
- sylius.behat.context.transform.product
- sylius.behat.context.transform.shipping_method
- sylius.behat.context.transform.user

- sylius.behat.context.setup.channel
- sylius.behat.context.setup.currency
- sylius.behat.context.setup.customer
- sylius.behat.context.setup.order
- sylius.behat.context.setup.payment
- sylius.behat.context.setup.product
- sylius.behat.context.setup.shipping
- sylius.behat.context.setup.shop_api_security
- sylius.behat.context.setup.user

- sylius.behat.context.api.shop.account
- sylius.behat.context.api.shop.order

filters:
tags: "@customer_account && @api"
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,7 @@
<property name="adjustments" writable="false">
<subresource resourceClass="%sylius.model.adjustment.class%" />
</property>
<property name="billingAddress" writable="false" />
<property name="shippingAddress" writable="false" />
</resource>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,37 @@
<attribute name="firstName">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="lastName">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="city">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="street">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="postcode">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="countryCode">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
<attribute name="provinceName">
<group>cart:address</group>
<group>checkout:read</group>
<group>order:read</group>
</attribute>
</class>
</serializer>
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
>
<class name="Sylius\Bundle\ApiBundle\Command\Checkout\AddressOrder">
<attribute name="billingAddress">
<group>cart:address</group>
<group>cart:address</group>
</attribute>
<attribute name="shippingAddress">
<group>cart:address</group>
<group>cart:address</group>
</attribute>
<attribute name="email">
<group>cart:address</group>
<group>cart:address</group>
</attribute>
</class>
</serializer>
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@

<attribute name="shippingAddress">
<group>checkout:read</group>
<group>order:read</group>
</attribute>

<attribute name="billingAddress">
<group>checkout:read</group>
<group>order:read</group>
</attribute>
</class>
</serializer>