mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Add tests
This commit is contained in:
parent
a24e225577
commit
60885a9634
8 changed files with 103 additions and 29 deletions
|
|
@ -6,14 +6,14 @@ Feature: Accessing payment's order from the payment index
|
|||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has "UPS" shipping method with "$10.00" fee
|
||||
And the store ships everywhere for free
|
||||
And the store has a product "Apple"
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is a new "#00000001" order with "Apple" product
|
||||
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
|
||||
When I browse payments
|
||||
And I move to the details of first payment's order
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ Feature: Browsing payments
|
|||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has "UPS" shipping method with "$10.00" fee
|
||||
And the store ships everywhere for free
|
||||
And the store has a product "Apple"
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is a new "#00000001" order with "Apple" product
|
||||
And there is an "#00000001" order with "Apple" product
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
|
|
|
|||
|
|
@ -1,24 +1,74 @@
|
|||
@managing_payments
|
||||
Feature: Filtering payments by state
|
||||
In order to filter payments by state
|
||||
In order to browse all payments with a chosen state
|
||||
As an Administrator
|
||||
I want to browse all payments with chosen state
|
||||
I want to filter payments by state
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has "UPS" shipping method with "$10.00" fee
|
||||
And the store ships everywhere for free
|
||||
And the store has a product "Apple"
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is a new "#00000001" order with "Apple" product
|
||||
And there is a new "#00000002" order with "Apple" product
|
||||
And there is a "New" "#00000001" order with "Apple" product
|
||||
And there is a "Completed" "#00000002" order with "Apple" product
|
||||
And there is a "Processing" "#00000003" order with "Apple" product
|
||||
And there is a "Refunded" "#00000004" order with "Apple" product
|
||||
And there is a "Cancelled" "#00000005" order with "Apple" product
|
||||
And there is a "Failed" "#00000006" order with "Apple" product
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state
|
||||
Scenario: Filtering payments by a chosen state "New"
|
||||
When I browse payments
|
||||
And I complete the payment of order "#00000002"
|
||||
And I choose "New" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
Then I should see "3" payments in the list
|
||||
And I should see the payment of the "#00000001" order
|
||||
And I should see also the payment of the "#00000005" order
|
||||
And I should see also the payment of the "#00000006" order
|
||||
But I should not see a payment of order "#00000002"
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state "Completed"
|
||||
When I browse payments
|
||||
And I choose "Completed" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
And I should see the payment of the "#00000002" order
|
||||
But I should not see a payment of order "#00000003"
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state "Processing"
|
||||
When I browse payments
|
||||
And I choose "Processing" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
And I should see the payment of the "#00000003" order
|
||||
But I should not see a payment of order "#00000004"
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state "Refunded"
|
||||
When I browse payments
|
||||
And I choose "Refunded" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
And I should see the payment of the "#00000004" order
|
||||
But I should not see a payment of order "#00000005"
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state "Cancelled"
|
||||
When I browse payments
|
||||
And I choose "Cancelled" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
And I should see the payment of the "#00000005" order
|
||||
But I should not see a payment of order "#00000006"
|
||||
|
||||
@ui
|
||||
Scenario: Filtering payments by a chosen state "Failed"
|
||||
When I browse payments
|
||||
And I choose "Failed" as a payment state
|
||||
And I filter
|
||||
Then I should see a single payment in the list
|
||||
And I should see the payment of the "#00000006" order
|
||||
But I should not see a payment of order "#00000001"
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ Feature: Completing a payment from its list
|
|||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has "UPS" shipping method with "$10.00" fee
|
||||
And the store ships everywhere for free
|
||||
And the store has a product "Apple"
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is a new "#00000001" order with "Apple" product
|
||||
And there is an "#00000001" order with "Apple" product
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
|
|
|
|||
|
|
@ -402,9 +402,10 @@ final class OrderContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Given there is a new :orderNumber order with :product product
|
||||
* @Given there is an :orderNumber order with :product product
|
||||
* @Given there is a :state :orderName order with :product product
|
||||
*/
|
||||
public function thereIsAnNewOrderWithProduct(string $orderNumber, ProductInterface $product): void
|
||||
public function thereIsAOrderWithProduct(string $orderNumber, ProductInterface $product, string $state = null): void
|
||||
{
|
||||
$order = $this->createOrder($this->createOrProvideCustomer('amba@fatima.org'), $orderNumber);
|
||||
|
||||
|
|
@ -414,6 +415,12 @@ final class OrderContext implements Context
|
|||
|
||||
$this->createShippingPaymentMethodsAndAddress();
|
||||
|
||||
if ($state !== null) {
|
||||
foreach($this->getTargetPaymentTransitions($state) as $transition) {
|
||||
$this->applyPaymentTransitionOnOrder($order, $transition);
|
||||
}
|
||||
}
|
||||
|
||||
$this->orderRepository->add($order);
|
||||
}
|
||||
|
||||
|
|
@ -955,6 +962,22 @@ final class OrderContext implements Context
|
|||
$this->objectManager->flush();
|
||||
}
|
||||
|
||||
private function getTargetPaymentTransitions(string $state): array
|
||||
{
|
||||
$state = strtolower($state);
|
||||
|
||||
$transitions = [
|
||||
'new' => [],
|
||||
'processing' => [PaymentTransitions::TRANSITION_PROCESS],
|
||||
'completed' => [PaymentTransitions::TRANSITION_COMPLETE],
|
||||
'cancelled' => [PaymentTransitions::TRANSITION_CANCEL],
|
||||
'failed' => [PaymentTransitions::TRANSITION_FAIL],
|
||||
'refunded' => [PaymentTransitions::TRANSITION_COMPLETE, PaymentTransitions::TRANSITION_REFUND]
|
||||
];
|
||||
|
||||
return $transitions[$state];
|
||||
}
|
||||
|
||||
private function placeOrder(
|
||||
ProductInterface $product,
|
||||
ShippingMethodInterface $shippingMethod,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use Sylius\Behat\NotificationType;
|
|||
use Sylius\Behat\Page\Admin\Order\ShowPageInterface;
|
||||
use Sylius\Behat\Page\Admin\Payment\IndexPageInterface;
|
||||
use Sylius\Behat\Service\NotificationCheckerInterface;
|
||||
use Sylius\Component\Core\Model\Channel;
|
||||
use Sylius\Component\Core\Model\CustomerInterface;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
|
@ -46,8 +45,9 @@ final class ManagingPaymentsContext implements Context
|
|||
|
||||
/**
|
||||
* @When I browse payments
|
||||
* @Given I am browsing payments
|
||||
*/
|
||||
public function iBrowsePayments(): void
|
||||
public function iAmBrowsingPayments(): void
|
||||
{
|
||||
$this->indexPage->open();
|
||||
}
|
||||
|
|
@ -77,9 +77,9 @@ final class ManagingPaymentsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When I move to the details of first payment's order
|
||||
* @When I go to the details of the first payment's order
|
||||
*/
|
||||
public function iMoveToTheDetailsOfFirstPaymentSOrder(): void
|
||||
public function iGoToTheDetailsOfTheFirstPaymentSOrder(): void
|
||||
{
|
||||
$this->indexPage->showOrderPageForNthPayment(1);
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ final class ManagingPaymentsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see the payment of the :orderNumber order
|
||||
* @Then I should see (also) the payment of the :orderNumber order
|
||||
*/
|
||||
public function iShouldSeeThePaymentOfTheOrder(string $orderNumber): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@
|
|||
<argument key="paypal_express_checkout">Paypal Express Checkout</argument>
|
||||
<argument key="stripe_checkout">Stripe Checkout</argument>
|
||||
</argument>
|
||||
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.setup.product" class="Sylius\Behat\Context\Setup\ProductContext">
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ sylius_grid:
|
|||
label: sylius.ui.state
|
||||
form_options:
|
||||
choices:
|
||||
sylius.ui.new: New
|
||||
sylius.ui.processing: Processing
|
||||
sylius.ui.completed: Completed
|
||||
sylius.ui.cancelled: Cancelled
|
||||
sylius.ui.failed: Failed
|
||||
sylius.ui.refunded: Refunded
|
||||
sylius.ui.cancelled: cancelled
|
||||
sylius.ui.completed: completed
|
||||
sylius.ui.failed: failed
|
||||
sylius.ui.new: new
|
||||
sylius.ui.processing: processing
|
||||
sylius.ui.refunded: refunded
|
||||
actions:
|
||||
item:
|
||||
complete:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue