mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
[Admin][PaymentRequest] Add behat tests
This commit is contained in:
parent
2d65680fb0
commit
e4cbd6b46a
26 changed files with 718 additions and 27 deletions
|
|
@ -0,0 +1,25 @@
|
|||
@managing_payments
|
||||
Feature: Browsing payment requests
|
||||
In order to have an overview of all payment requests of a specific payment
|
||||
As an Administrator
|
||||
I want to browse all payment requests of a payment
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "PHP T-Shirt"
|
||||
And the store ships everywhere for Free
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is an "#00000001" order with "PHP T-Shirt" product
|
||||
And the payment request action "authorize" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And the payment request action "capture" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And the payment request action "sync" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@api @ui
|
||||
Scenario: Browsing payment requests of a payment
|
||||
When I browse payments
|
||||
And I want to view the payment request of the first payment
|
||||
Then there should be 3 payment requests on the list
|
||||
And it should be the payment request with action "authorize"
|
||||
And it should be the payment request with action "capture"
|
||||
And it should be the payment request with action "sync"
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
@managing_payments
|
||||
Feature: Filtering payment requests
|
||||
In order to see specific payment requests
|
||||
As an Administrator
|
||||
I want to be able to filter payment requests on the list
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "PHP T-Shirt"
|
||||
And the store ships everywhere for Free
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And the store allows paying with "Credit Card"
|
||||
And there is an "#00000001" order with "PHP T-Shirt" product
|
||||
And there is an "#00000002" order with "PHP T-Shirt" product
|
||||
And the payment request action "authorize" has been executed for order "#00000001" with the payment method "Credit Card"
|
||||
And the payment request action "authorize" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And the payment request action "capture" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And the payment request action "sync" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And the payment request action "capture" has been executed for order "#00000002" with the payment method "Cash on Delivery"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@api @ui
|
||||
Scenario: Filtering payment requests by action
|
||||
When I browse payment requests of an order "#00000001"
|
||||
And I filter by the "capture" action
|
||||
Then there should be 1 payment request on the list
|
||||
And it should be the payment request with action "capture"
|
||||
|
||||
@api @ui @mink:chromedriver
|
||||
Scenario: Filtering payment requests by payment method
|
||||
When I browse payment requests of an order "#00000001"
|
||||
And I filter by the "Credit Card" payment method
|
||||
Then there should be 1 payment request on the list
|
||||
And it should be the payment request with payment method "Credit Card"
|
||||
|
||||
@api @ui
|
||||
Scenario: Filtering payment requests by state "New"
|
||||
When I browse payment requests of an order "#00000001"
|
||||
And I filter by the "new" state
|
||||
Then there should be 4 payment requests on the list
|
||||
|
||||
@api @ui
|
||||
Scenario: Filtering payment requests by state "Completed"
|
||||
When I browse payment requests of an order "#00000001"
|
||||
And I filter by the "completed" state
|
||||
Then there should be 0 payment request on the list
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
@managing_payments
|
||||
Feature: Seeing payment request details
|
||||
In order to have an overview of one of payment requests
|
||||
As an Administrator
|
||||
I want to be able to see its details
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "PHP T-Shirt"
|
||||
And the store ships everywhere for Free
|
||||
And the store allows paying with "Cash on Delivery"
|
||||
And there is an "#00000001" order with "PHP T-Shirt" product
|
||||
And the payment request action "authorize" has been executed for order "#00000001" with the payment method "Cash on Delivery"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@api @ui
|
||||
Scenario: Seeing payment request's details
|
||||
When I view details of the payment request for the "#00000001" order
|
||||
Then its method should be "Cash on Delivery"
|
||||
And its action should be "Authorize"
|
||||
And its state should be "New"
|
||||
And its payload should has empty value
|
||||
And its response data should has empty value
|
||||
|
|
@ -21,7 +21,7 @@ Feature: Changing the offline payment method after order confirmation
|
|||
And I retry the payment with "Offline" payment method
|
||||
Then I should have chosen "Offline" payment method
|
||||
|
||||
@api @ui @javascript
|
||||
@api
|
||||
Scenario: Retrying the payment with different Offline payment works correctly together with inventory
|
||||
Given there is 1 unit of product "PHP T-Shirt" available in the inventory
|
||||
And this product is tracked by the inventory
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ final class ApiPlatformClient implements ApiClientInterface
|
|||
/** @param array<string, string> $queryParameters */
|
||||
public function subResourceIndex(string $resource, string $subResource, string $id, array $queryParameters = [], bool $forgetResponse = false): Response
|
||||
{
|
||||
$request = $this->requestFactory->subResourceIndex($this->section, $resource, $id, $subResource, $queryParameters);
|
||||
$request->authorize($this->getToken(), $this->authorizationHeader);
|
||||
$this->request = $this->requestFactory->subResourceIndex($this->section, $resource, $id, $subResource, $queryParameters);
|
||||
$this->request->authorize($this->getToken(), $this->authorizationHeader);
|
||||
|
||||
return $this->request($request, $forgetResponse);
|
||||
return $this->request($this->request, $forgetResponse);
|
||||
}
|
||||
|
||||
public function show(string $resource, string $id, bool $forgetResponse = false): Response
|
||||
|
|
|
|||
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Context\Api\Admin;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Client\ApiClientInterface;
|
||||
use Sylius\Behat\Client\ResponseCheckerInterface;
|
||||
use Sylius\Behat\Context\Api\Resources;
|
||||
use Sylius\Behat\Service\Converter\IriConverterInterface;
|
||||
use Sylius\Component\Core\Formatter\StringInflector;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\CustomerInterface;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\PaymentMethodInterface;
|
||||
use Sylius\Component\Payment\PaymentTransitions;
|
||||
use Sylius\Component\Payment\Repository\PaymentRequestRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final readonly class ManagingPaymentRequestsContext implements Context
|
||||
{
|
||||
public function __construct(
|
||||
private ApiClientInterface $client,
|
||||
private ResponseCheckerInterface $responseChecker,
|
||||
private IriConverterInterface $iriConverter,
|
||||
private PaymentRequestRepositoryInterface $paymentRequestRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I browse payment requests of an order :order
|
||||
*/
|
||||
public function iBrowseOrdersOfACustomer(OrderInterface $order): void
|
||||
{
|
||||
$this->client->subResourceIndex(
|
||||
Resources::PAYMENTS,
|
||||
Resources::PAYMENT_REQUESTS,
|
||||
(string) $order->getLastPayment()->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I view details of the payment request for the :order order
|
||||
*/
|
||||
public function iViewDetailsOfThePaymentRequestForTheOrder(OrderInterface $order): void
|
||||
{
|
||||
$paymentRequest = $this->paymentRequestRepository->findOneBy(['payment' => $order->getLastPayment()]);
|
||||
|
||||
$this->client->show(Resources::PAYMENT_REQUESTS, (string) $paymentRequest->getHash());
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :action action
|
||||
*/
|
||||
public function iFilterByTheAction(string $action): void
|
||||
{
|
||||
$this->client->addFilter('action', $action);
|
||||
$this->client->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :paymentMethod payment method
|
||||
*/
|
||||
public function iFilterByThePaymentMethod(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
$this->client->addFilter('method.code', $paymentMethod->getCode());
|
||||
$this->client->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :state state
|
||||
*/
|
||||
public function iFilterByTheState(string $state): void
|
||||
{
|
||||
$this->client->addFilter('state', $state);
|
||||
$this->client->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^there should be (\d+) payment requests? on the list$/
|
||||
*/
|
||||
public function thereShouldBeProductVariantsOnTheList(int $count): void
|
||||
{
|
||||
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then it should be the payment request with action :action
|
||||
*/
|
||||
public function itShouldBeThePaymentRequestWithAction(string $action): void
|
||||
{
|
||||
Assert::true($this->responseChecker->hasItemWithValue($this->client->getLastResponse(), 'action', $action));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then it should be the payment request with payment method :paymentMethod
|
||||
*/
|
||||
public function itShouldBeThePaymentRequestWithPaymentMethod(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
Assert::true(
|
||||
$this->responseChecker->hasItemWithValue(
|
||||
$this->client->getLastResponse(),
|
||||
'method',
|
||||
$this->iriConverter->getIriFromResourceInSection($paymentMethod, 'admin'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its method should be :paymentMethod
|
||||
*/
|
||||
public function itsMethodShouldBe(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
Assert::true($this->responseChecker->hasValue(
|
||||
$this->client->getLastResponse(),
|
||||
'method',
|
||||
$this->iriConverter->getIriFromResourceInSection($paymentMethod, 'admin'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^its (action|state) should be "([^"]+)"$/
|
||||
*/
|
||||
public function itsActionStateShouldBe(string $field, string $value): void
|
||||
{
|
||||
Assert::true($this->responseChecker->hasValue($this->client->getLastResponse(), $field, strtolower($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its payload should has empty value
|
||||
*/
|
||||
public function itsPayloadShouldHasEmptyValue(): void
|
||||
{
|
||||
Assert::isEmpty($this->responseChecker->getValue($this->client->getLastResponse(), 'payload'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its response data should has empty value
|
||||
*/
|
||||
public function itsResponseDataShouldHasEmptyValue(): void
|
||||
{
|
||||
Assert::isEmpty($this->responseChecker->getValue($this->client->getLastResponse(), 'responseData'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -58,6 +58,20 @@ final readonly class ManagingPaymentsContext implements Context
|
|||
$this->client->customItemAction(Resources::ORDERS, $order->getTokenValue(), HttpRequest::METHOD_GET, 'payments');
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I want to view the payment request of the first payment
|
||||
*/
|
||||
public function iWantToViewThePaymentRequestOfTheFirstPayment(): void
|
||||
{
|
||||
$response = $this->client->getLastResponse();
|
||||
|
||||
$this->client->subResourceIndex(
|
||||
Resources::PAYMENTS,
|
||||
Resources::PAYMENT_REQUESTS,
|
||||
(string) $this->responseChecker->getCollection($response)[0]['id']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see the details of order :order
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,14 +15,13 @@ use Sylius\Component\Core\Model\PaymentMethodInterface;
|
|||
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request as HTTPRequest;
|
||||
|
||||
final class PaymentRequestContext implements Context
|
||||
final readonly class PaymentRequestContext implements Context
|
||||
{
|
||||
public function __construct(
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private ApiClientInterface $client,
|
||||
private ResponseCheckerInterface $responseChecker,
|
||||
private RequestFactoryInterface $requestFactory,
|
||||
private PaymentMethodRepositoryInterface $paymentMethodRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
|
|||
use Sylius\Bundle\PayumBundle\Model\GatewayConfigInterface;
|
||||
use Sylius\Component\Core\Formatter\StringInflector;
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\PaymentMethodInterface;
|
||||
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;
|
||||
use Sylius\Component\Payment\Repository\PaymentMethodRepositoryInterface;
|
||||
use Sylius\Resource\Factory\FactoryInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final readonly class PaymentContext implements Context
|
||||
{
|
||||
|
|
@ -72,7 +70,7 @@ final readonly class PaymentContext implements Context
|
|||
/**
|
||||
* @Given /^the store allows paying (\w+) for (all channels)$/
|
||||
*/
|
||||
public function storeAllowsPayingForAllChannels($paymentMethodName, array $channels)
|
||||
public function storeAllowsPayingForAllChannels($paymentMethodName, array $channels): void
|
||||
{
|
||||
$paymentMethod = $this->createPaymentMethod($paymentMethodName, StringInflector::nameToUppercaseCode($paymentMethodName), 'Offline', 'Payment method', false);
|
||||
|
||||
|
|
@ -92,7 +90,7 @@ final readonly class PaymentContext implements Context
|
|||
/**
|
||||
* @Given /^(this payment method) is named "([^"]+)" in the "([^"]+)" locale$/
|
||||
*/
|
||||
public function thisPaymentMethodIsNamedIn(PaymentMethodInterface $paymentMethod, $name, $locale)
|
||||
public function thisPaymentMethodIsNamedIn(PaymentMethodInterface $paymentMethod, $name, $locale): void
|
||||
{
|
||||
/** @var PaymentMethodTranslationInterface $translation */
|
||||
$translation = $this->paymentMethodTranslationFactory->createNew();
|
||||
|
|
@ -109,7 +107,7 @@ final readonly class PaymentContext implements Context
|
|||
* @Given /^(this payment method) (?:has been|is) disabled$/
|
||||
* @When the payment method :paymentMethod gets disabled
|
||||
*/
|
||||
public function theStoreHasAPaymentMethodDisabled(PaymentMethodInterface $paymentMethod)
|
||||
public function theStoreHasAPaymentMethodDisabled(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
$paymentMethod->disable();
|
||||
|
||||
|
|
@ -119,7 +117,7 @@ final readonly class PaymentContext implements Context
|
|||
/**
|
||||
* @Given /^(it) has instructions "([^"]+)"$/
|
||||
*/
|
||||
public function itHasInstructions(PaymentMethodInterface $paymentMethod, $instructions)
|
||||
public function itHasInstructions(PaymentMethodInterface $paymentMethod, $instructions): void
|
||||
{
|
||||
$paymentMethod->setInstructions($instructions);
|
||||
|
||||
|
|
@ -129,7 +127,7 @@ final readonly class PaymentContext implements Context
|
|||
/**
|
||||
* @Given the store has :paymentMethodName payment method not assigned to any channel
|
||||
*/
|
||||
public function theStoreHasPaymentMethodNotAssignedToAnyChannel($paymentMethodName)
|
||||
public function theStoreHasPaymentMethodNotAssignedToAnyChannel($paymentMethodName): void
|
||||
{
|
||||
$this->createPaymentMethod($paymentMethodName, 'PM_' . $paymentMethodName, 'Offline', 'Payment method', false);
|
||||
}
|
||||
|
|
@ -137,7 +135,7 @@ final readonly class PaymentContext implements Context
|
|||
/**
|
||||
* @Given the payment method :paymentMethod requires authorization before capturing
|
||||
*/
|
||||
public function thePaymentMethodRequiresAuthorizationBeforeCapturing(PaymentMethodInterface $paymentMethod)
|
||||
public function thePaymentMethodRequiresAuthorizationBeforeCapturing(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
/** @var GatewayConfigInterface $config */
|
||||
$config = $paymentMethod->getGatewayConfig();
|
||||
|
|
@ -163,16 +161,6 @@ final readonly class PaymentContext implements Context
|
|||
$paymentMethod->addChannel($channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the (latest order) should have a payment with state "([^"]+)"$/
|
||||
*/
|
||||
public function theLatestOrderHasAuthorizedPayment(OrderInterface $order, string $state)
|
||||
{
|
||||
$payment = $order->getLastPayment();
|
||||
|
||||
Assert::eq($payment->getState(), $state);
|
||||
}
|
||||
|
||||
private function createPaymentMethod(
|
||||
string $name,
|
||||
string $code,
|
||||
|
|
|
|||
45
src/Sylius/Behat/Context/Setup/PaymentRequestContext.php
Normal file
45
src/Sylius/Behat/Context/Setup/PaymentRequestContext.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Context\Setup;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Bundle\ApiBundle\Command\Payment\AddPaymentRequest;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\PaymentMethodInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
|
||||
final readonly class PaymentRequestContext implements Context
|
||||
{
|
||||
public function __construct(
|
||||
private MessageBusInterface $commandBus,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given the payment request action :action has been executed for order :order with the payment method :paymentMethod
|
||||
*/
|
||||
public function thePaymentRequestActionHasBeenExecutedForOrderWithThePaymentMethod(
|
||||
string $action,
|
||||
OrderInterface $order,
|
||||
PaymentMethodInterface $paymentMethod
|
||||
): void {
|
||||
$addPaymentRequest = new AddPaymentRequest(
|
||||
paymentId: $order->getLastPayment()->getId(),
|
||||
paymentMethodCode: $paymentMethod->getCode(),
|
||||
action: $action,
|
||||
);
|
||||
|
||||
$this->commandBus->dispatch($addPaymentRequest);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Context\Ui\Admin;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Page\Admin\Payment\PaymentRequest\IndexPageInterface;
|
||||
use Sylius\Behat\Page\Admin\Payment\PaymentRequest\ShowPageInterface;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\Model\PaymentMethodInterface;
|
||||
use Sylius\Component\Payment\Repository\PaymentRequestRepositoryInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final readonly class ManagingPaymentRequestsContext implements Context
|
||||
{
|
||||
public function __construct(
|
||||
private IndexPageInterface $indexPage,
|
||||
private ShowPageInterface $showPage,
|
||||
private PaymentRequestRepositoryInterface $paymentRequestRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I browse payment requests of an order :order
|
||||
*/
|
||||
public function iBrowseOrdersOfACustomer(OrderInterface $order): void
|
||||
{
|
||||
$this->indexPage->open(['id' => $order->getLastPayment()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I view details of the payment request for the :order order
|
||||
*/
|
||||
public function iViewDetailsOfThePaymentRequestForTheOrder(OrderInterface $order): void
|
||||
{
|
||||
$payment = $order->getLastPayment();
|
||||
$paymentRequest = $this->paymentRequestRepository->findOneBy(['payment' => $payment]);
|
||||
|
||||
$this->showPage->open([
|
||||
'hash' => $paymentRequest->getHash(),
|
||||
'paymentId' => $payment->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :action action
|
||||
*/
|
||||
public function iFilterByTheAction(string $action): void
|
||||
{
|
||||
$this->indexPage->chooseActionToFilter($action);
|
||||
$this->indexPage->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :paymentMethod payment method
|
||||
*/
|
||||
public function iFilterByThePaymentMethod(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
$this->indexPage->choosePaymentMethodToFilter($paymentMethod->getName());
|
||||
$this->indexPage->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter by the :state state
|
||||
*/
|
||||
public function iFilterByTheState(string $state): void
|
||||
{
|
||||
$this->indexPage->chooseStateToFilter($state);
|
||||
$this->indexPage->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^there should be (\d+) payment requests? on the list$/
|
||||
*/
|
||||
public function thereShouldBeProductVariantsOnTheList(int $count): void
|
||||
{
|
||||
Assert::same(
|
||||
$this->indexPage->countItems(),
|
||||
$count,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then it should be the payment request with action :action
|
||||
*/
|
||||
public function itShouldBeThePaymentRequestWithAction(string $action): void
|
||||
{
|
||||
Assert::true($this->indexPage->isSingleResourceOnPage(['action' => $action]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then it should be the payment request with payment method :paymentMethod
|
||||
*/
|
||||
public function itShouldBeThePaymentRequestWithPaymentMethod(PaymentMethodInterface $paymentMethod): void
|
||||
{
|
||||
Assert::true($this->indexPage->isSingleResourceOnPage(['method' => $paymentMethod->getName()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its :field should be :value
|
||||
*/
|
||||
public function itsFieldShouldBe(string $field, string $value): void
|
||||
{
|
||||
Assert::same($this->showPage->getFieldText($field), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its payload should has empty value
|
||||
*/
|
||||
public function itsPayloadShouldHasEmptyValue(): void
|
||||
{
|
||||
Assert::same($this->showPage->getFieldText('payload'), 'null');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then its response data should has empty value
|
||||
*/
|
||||
public function itsResponseDataShouldBe(): void
|
||||
{
|
||||
Assert::same($this->showPage->getFieldText('response_data'), json_encode([]));
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +80,14 @@ final class ManagingPaymentsContext implements Context
|
|||
$this->indexPage->chooseChannelFilter($channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I want to view the payment request of the first payment
|
||||
*/
|
||||
public function iWantToViewThePaymentRequestOfTheFirstPayment(): void
|
||||
{
|
||||
$this->indexPage->showPaymentRequestOfNthPayment(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :count payments in the list
|
||||
* @Then I should see a single payment in the list
|
||||
|
|
|
|||
|
|
@ -48,6 +48,17 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
|
|||
$this->getOrderLinkForRow($position)->clickLink('#');
|
||||
}
|
||||
|
||||
public function showPaymentRequestOfNthPayment(int $position): void
|
||||
{
|
||||
$tableAccessor = $this->getTableAccessor();
|
||||
$table = $this->getElement('table');
|
||||
|
||||
$row = $tableAccessor->getRowsWithFields($table, [])[$position];
|
||||
$field = $tableAccessor->getFieldFromRow($table, $row, 'actions');
|
||||
|
||||
$field->find('css', '[data-test-show-action="List payment requests"]')->click();
|
||||
}
|
||||
|
||||
public function chooseChannelFilter(string $channelName): void
|
||||
{
|
||||
$this->getElement('filter_channel')->selectOption($channelName);
|
||||
|
|
|
|||
|
|
@ -27,5 +27,7 @@ interface IndexPageInterface extends BaseIndexPageInterface
|
|||
|
||||
public function showOrderPageForNthPayment(int $position): void;
|
||||
|
||||
public function showPaymentRequestOfNthPayment(int $position): void;
|
||||
|
||||
public function chooseChannelFilter(string $channelName): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Page\Admin\Payment\PaymentRequest;
|
||||
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Behat\Mink\Session;
|
||||
use Sylius\Behat\Page\Admin\Crud\IndexPage as BaseIndexPage;
|
||||
use Sylius\Behat\Service\Accessor\TableAccessorInterface;
|
||||
use Sylius\Behat\Service\Helper\AutocompleteHelperInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
class IndexPage extends BaseIndexPage implements IndexPageInterface
|
||||
{
|
||||
public function __construct(
|
||||
Session $session,
|
||||
$minkParameters,
|
||||
RouterInterface $router,
|
||||
TableAccessorInterface $tableAccessor,
|
||||
string $routeName,
|
||||
private readonly AutocompleteHelperInterface $autocompleteHelper,
|
||||
) {
|
||||
parent::__construct($session, $minkParameters, $router, $tableAccessor, $routeName);
|
||||
}
|
||||
|
||||
public function choosePaymentMethodToFilter(string $paymentMethodName): void
|
||||
{
|
||||
$this->specifyAutocompleteFilter($this->getElement('filter_payment_method'), $paymentMethodName);
|
||||
}
|
||||
|
||||
public function chooseActionToFilter(string $action): void
|
||||
{
|
||||
$this->getElement('filter_action')->selectOption($action);
|
||||
}
|
||||
|
||||
public function chooseStateToFilter(string $state): void
|
||||
{
|
||||
$this->getElement('filter_state')->selectOption($state);
|
||||
}
|
||||
|
||||
protected function getDefinedElements(): array
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'filter_action' => '#criteria_action',
|
||||
'filter_payment_method' => '#criteria_payment_method',
|
||||
'filter_state' => '#criteria_state',
|
||||
]);
|
||||
}
|
||||
|
||||
private function specifyAutocompleteFilter(NodeElement $autocomplete, string $value): void
|
||||
{
|
||||
if (!$this->areFiltersVisible()) {
|
||||
$this->toggleFilters();
|
||||
}
|
||||
|
||||
$this->autocompleteHelper->selectByName(
|
||||
$this->getDriver(),
|
||||
$autocomplete->getXpath(),
|
||||
$value,
|
||||
);
|
||||
|
||||
$this->waitForFormUpdate();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Page\Admin\Payment\PaymentRequest;
|
||||
|
||||
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface as BaseIndexPageInterface;
|
||||
|
||||
interface IndexPageInterface extends BaseIndexPageInterface
|
||||
{
|
||||
public function choosePaymentMethodToFilter(string $paymentMethodName): void;
|
||||
|
||||
public function chooseActionToFilter(string $action): void;
|
||||
|
||||
public function chooseStateToFilter(string $state): void;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Page\Admin\Payment\PaymentRequest;
|
||||
|
||||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage;
|
||||
|
||||
class ShowPage extends SymfonyPage implements ShowPageInterface
|
||||
{
|
||||
public function getRouteName(): string
|
||||
{
|
||||
return 'sylius_admin_payment_payment_request_show';
|
||||
}
|
||||
|
||||
public function getFieldText(string $fieldName): string
|
||||
{
|
||||
return $this->getElement($fieldName)->getText();
|
||||
}
|
||||
|
||||
protected function getDefinedElements(): array
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'action' => '[data-test-action]',
|
||||
'method' => '[data-test-method]',
|
||||
'payload' => '[data-test-payload]',
|
||||
'response_data' => '[data-test-response-data]',
|
||||
'state' => '[data-test-state]',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Page\Admin\Payment\PaymentRequest;
|
||||
|
||||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface;
|
||||
|
||||
interface ShowPageInterface extends SymfonyPageInterface
|
||||
{
|
||||
public function getFieldText(string $fieldName): string;
|
||||
}
|
||||
|
|
@ -302,5 +302,12 @@
|
|||
<argument type="service" id="api_platform.symfony.iri_converter" />
|
||||
<argument type="service" id="sylius.behat.shared_storage" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.api.admin.managing_payment_requests" class="Sylius\Behat\Context\Api\Admin\ManagingPaymentRequestsContext">
|
||||
<argument type="service" id="sylius.behat.api_platform_client.admin" />
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="api_platform.symfony.iri_converter" />
|
||||
<argument type="service" id="sylius.repository.payment_request" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@
|
|||
<argument type="service" id="sylius.behat.api_platform_client.shop" />
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.request_factory" />
|
||||
<argument type="service" id="sylius.repository.payment_method" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.api.shop.payment" class="Sylius\Behat\Context\Api\Shop\PaymentContext">
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@
|
|||
<argument type="collection">
|
||||
<argument key="offline">Offline</argument>
|
||||
</argument>
|
||||
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Behat\Context\Setup\PriceHistoryContext">
|
||||
|
|
@ -320,5 +319,9 @@
|
|||
<argument type="service" id="sylius.event_bus" />
|
||||
<argument type="service" id="sylius.behat.shared_storage" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.setup.payment_request" class="Sylius\Behat\Context\Setup\PaymentRequestContext">
|
||||
<argument type="service" id="sylius.command_bus" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -613,5 +613,11 @@
|
|||
<service id="sylius.behat.context.ui.admin.search_filter" class="Sylius\Behat\Context\Ui\Admin\SearchFilterContext">
|
||||
<argument type="service" id="sylius.behat.element.admin.crud.index.search_filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.ui.admin.managing_payment_requests" class="Sylius\Behat\Context\Ui\Admin\ManagingPaymentRequestsContext">
|
||||
<argument type="service" id="sylius.behat.page.admin.payment.payment_request.index" />
|
||||
<argument type="service" id="sylius.behat.page.admin.payment.payment_request.show"/>
|
||||
<argument type="service" id="sylius.repository.payment_request"/>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<parameters>
|
||||
<parameter key="sylius.behat.page.admin.payment.index.class">Sylius\Behat\Page\Admin\Payment\IndexPage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.payment.payment_request.index.class">Sylius\Behat\Page\Admin\Payment\PaymentRequest\IndexPage</parameter>
|
||||
<parameter key="sylius.behat.page.admin.payment.payment_request.show.class">Sylius\Behat\Page\Admin\Payment\PaymentRequest\ShowPage</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
|
|
@ -22,5 +24,21 @@
|
|||
<service id="sylius.behat.page.admin.payment.index" class="%sylius.behat.page.admin.payment.index.class%" parent="sylius.behat.page.admin.crud.index" public="false">
|
||||
<argument type="string">sylius_admin_payment_index</argument>
|
||||
</service>
|
||||
|
||||
<service
|
||||
id="sylius.behat.page.admin.payment.payment_request.index"
|
||||
class="%sylius.behat.page.admin.payment.payment_request.index.class%"
|
||||
parent="sylius.behat.page.admin.crud.index"
|
||||
>
|
||||
<argument type="string">sylius_admin_payment_payment_request_index</argument>
|
||||
<argument type="service" id="Sylius\Behat\Service\Helper\AutocompleteHelperInterface" />
|
||||
</service>
|
||||
|
||||
<service
|
||||
id="sylius.behat.page.admin.payment.payment_request.show"
|
||||
class="%sylius.behat.page.admin.payment.payment_request.show.class%"
|
||||
parent="sylius.behat.symfony_page"
|
||||
>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ default:
|
|||
- 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.shared_storage
|
||||
|
||||
|
|
@ -18,10 +19,12 @@ default:
|
|||
- sylius.behat.context.setup.channel
|
||||
- sylius.behat.context.setup.order
|
||||
- sylius.behat.context.setup.payment
|
||||
- sylius.behat.context.setup.payment_request
|
||||
- sylius.behat.context.setup.product
|
||||
- sylius.behat.context.setup.shipping
|
||||
|
||||
- sylius.behat.context.api.admin.managing_payments
|
||||
- sylius.behat.context.api.admin.managing_payment_requests
|
||||
|
||||
filters:
|
||||
tags: "@managing_payments&&@api"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ default:
|
|||
- sylius.behat.context.setup.geographical
|
||||
- sylius.behat.context.setup.order
|
||||
- sylius.behat.context.setup.payment
|
||||
- sylius.behat.context.setup.payment_request
|
||||
- sylius.behat.context.setup.product
|
||||
- sylius.behat.context.setup.shipping
|
||||
- sylius.behat.context.setup.zone
|
||||
|
|
@ -30,6 +31,7 @@ default:
|
|||
- sylius.behat.context.ui.email
|
||||
|
||||
- sylius.behat.context.ui.admin.managing_payments
|
||||
- sylius.behat.context.ui.admin.managing_payment_requests
|
||||
- sylius.behat.context.ui.shop.cart
|
||||
filters:
|
||||
tags: "@managing_payments&&@ui"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"@context": "\/api\/v2\/contexts\/PaymentRequest",
|
||||
"@id": "\/api\/v2\/admin\/payments\/@integer@\/payment-requests",
|
||||
"@type": "hydra:Collection",
|
||||
"hydra:totalItems": 3,
|
||||
"hydra:member": [
|
||||
{
|
||||
"@id": "\/api\/v2\/admin\/payment-requests\/@string@",
|
||||
|
|
@ -31,5 +32,47 @@
|
|||
"method": "\/api\/v2\/admin\/payment-methods\/CASH_ON_DELIVERY"
|
||||
}
|
||||
],
|
||||
"hydra:totalItems": 3
|
||||
"hydra:search": {
|
||||
"@type": "hydra:IriTemplate",
|
||||
"hydra:template": "\/api\/v2\/admin\/payments\/@integer@\/payment-requests{?action,action[],method.code,method.code[],state,state[]}",
|
||||
"hydra:variableRepresentation": "BasicRepresentation",
|
||||
"hydra:mapping": [
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "action",
|
||||
"property": "action",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "action[]",
|
||||
"property": "action",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "method.code",
|
||||
"property": "method.code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "method.code[]",
|
||||
"property": "method.code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "state",
|
||||
"property": "state",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "state[]",
|
||||
"property": "state",
|
||||
"required": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue