mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Cover accessing order from payments and shipments
This commit is contained in:
parent
8cf586d08a
commit
b090f472c6
7 changed files with 69 additions and 6 deletions
|
|
@ -12,8 +12,8 @@ Feature: Accessing payment's order from the payment index
|
|||
And there is an "#00000001" order with "Apple" product
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
Scenario: Accessing payment's order from the payments index
|
||||
@ui @api
|
||||
Scenario: Accessing payment's order from the payment
|
||||
Given I am browsing payments
|
||||
When I go to the details of the first payment's order
|
||||
Then I should see order page with details of order "#00000001"
|
||||
Then I should see the details of order "#00000001"
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ Feature: Accessing shipment's order from the shipments index
|
|||
And the customer chose "UPS" shipping method with "Cash on Delivery" payment
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
Scenario: Accessing shipment's order from the shipments index
|
||||
@ui @api
|
||||
Scenario: Accessing shipment's order from the shipment
|
||||
When I browse shipments
|
||||
And I move to the details of first shipment's order
|
||||
Then I should see order page with details of order "00000001"
|
||||
Then I should see the details of order "#00000001"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Behat\Context\Api\Admin;
|
||||
|
||||
use ApiPlatform\Api\IriConverterInterface;
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Client\ApiClientInterface;
|
||||
use Sylius\Behat\Client\ResponseCheckerInterface;
|
||||
|
|
@ -23,6 +24,7 @@ use Sylius\Component\Core\Model\ChannelInterface;
|
|||
use Sylius\Component\Core\Model\CustomerInterface;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Payment\PaymentTransitions;
|
||||
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class ManagingPaymentsContext implements Context
|
||||
|
|
@ -31,6 +33,7 @@ final class ManagingPaymentsContext implements Context
|
|||
private ApiClientInterface $client,
|
||||
private ResponseCheckerInterface $responseChecker,
|
||||
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
|
||||
private IriConverterInterface $iriConverter,
|
||||
private string $apiUrlPrefix,
|
||||
) {
|
||||
}
|
||||
|
|
@ -44,6 +47,34 @@ final class ManagingPaymentsContext implements Context
|
|||
$this->client->index(Resources::PAYMENTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I go to the details of the first payment's order
|
||||
*/
|
||||
public function iGoToTheDetailsOfTheFirstPaymentSOrder(): void
|
||||
{
|
||||
$firstPayment = $this->responseChecker->getCollection($this->client->getLastResponse())[0];
|
||||
|
||||
/** @var OrderInterface $order */
|
||||
$order = $this->iriConverter->getResourceFromIri($firstPayment['order']);
|
||||
|
||||
$this->client->customItemAction(Resources::ORDERS, $order->getTokenValue(), HttpRequest::METHOD_GET, 'payments');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see the details of order :order
|
||||
*/
|
||||
public function iShouldSeeOrderWithDetails(OrderInterface $order): void
|
||||
{
|
||||
Assert::true(
|
||||
$this->responseChecker->hasItemWithValue(
|
||||
$this->client->getLastResponse(),
|
||||
'order',
|
||||
$this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
|
||||
),
|
||||
sprintf('Order with number %s does not exist', $order->getNumber()),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I complete the payment of order :order
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,6 +59,19 @@ final class ManagingShipmentsContext implements Context
|
|||
$this->client->addFilter('state', $state);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I move to the details of first shipment's order
|
||||
*/
|
||||
public function iMoveToDetailsOfFirstShipment(): void
|
||||
{
|
||||
$firstShipment = $this->responseChecker->getCollection($this->client->getLastResponse())[0];
|
||||
|
||||
/** @var OrderInterface $order */
|
||||
$order = $this->iriConverter->getResourceFromIri($firstShipment['order']);
|
||||
|
||||
$this->client->customItemAction(Resources::ORDERS, $order->getTokenValue(), HttpRequest::METHOD_GET, 'shipments');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I choose :channel as a channel filter
|
||||
*/
|
||||
|
|
@ -290,6 +303,21 @@ final class ManagingShipmentsContext implements Context
|
|||
Assert::same($productUnitsCounter, $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see the details of order :order
|
||||
*/
|
||||
public function iShouldSeeOrderWithDetails(OrderInterface $order): void
|
||||
{
|
||||
Assert::true(
|
||||
$this->responseChecker->hasItemWithValue(
|
||||
$this->client->getLastResponse(),
|
||||
'order',
|
||||
$this->sectionAwareIriConverter->getIriFromResourceInSection($order, 'admin'),
|
||||
),
|
||||
sprintf('Order with number %s does not exist', $order->getNumber()),
|
||||
);
|
||||
}
|
||||
|
||||
private function isShipmentForOrder(OrderInterface $order): bool
|
||||
{
|
||||
return $this->responseChecker->hasItemWithValue(
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ final class ManagingPaymentsContext implements Context
|
|||
|
||||
/**
|
||||
* @Then I should see order page with details of order :order
|
||||
* @Then I should see the details of order :order
|
||||
*/
|
||||
public function iShouldSeeOrderPageWithDetailsOfOrder(OrderInterface $order): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ final class ManagingShipmentsContext implements Context
|
|||
|
||||
/**
|
||||
* @Then I should see order page with details of order :order
|
||||
* @Then I should see the details of order :order
|
||||
*/
|
||||
public function iShouldSeeOrderPageWithDetailsOfOrder(OrderInterface $order): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@
|
|||
<argument type="service" id="sylius.behat.api_platform_client.admin" />
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.section_iri_converter" />
|
||||
<argument type="service" id="api_platform.iri_converter" />
|
||||
<argument>%sylius.security.new_api_route%</argument>
|
||||
</service>
|
||||
|
||||
|
|
@ -221,6 +222,7 @@
|
|||
<service id="sylius.behat.context.api.admin.managing_orders" class="Sylius\Behat\Context\Api\Admin\ManagingOrdersContext">
|
||||
<argument type="service" id="sylius.behat.api_platform_client.admin" />
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.request_factory" />
|
||||
<argument type="service" id="api_platform.iri_converter" />
|
||||
<argument type="service" id="sylius.behat.api_security" />
|
||||
<argument type="service" id="sylius.behat.shared_storage" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue