feature #15092 Cover Seeing payment method instructions behat API scenario (TheMilek)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13 <!-- see the comment below -->                  |
| Bug fix?        | no                                                       |
| New feature?    | no                                                       |
| BC breaks?      | no                                                     |
| License         | MIT                                                          |

<!--
 - Bug fixes must be submitted against the 1.12 branch
 - Features and deprecations must be submitted against the 1.13 branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

3c6002b63f Cover Seeing payment method instructions behat scenario
This commit is contained in:
Grzegorz Sadowski 2023-06-15 14:19:23 +02:00 committed by GitHub
commit 025df951b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 4 deletions

View file

@ -1,5 +1,5 @@
@paying_for_order
Feature: Seeing payment method instructions on thank you page
Feature: Seeing payment method instructions after checkout
In order to know how to pay for my order
As a Customer
I want to be informed about payment instructions for chosen payment method
@ -11,11 +11,10 @@ Feature: Seeing payment method instructions on thank you page
And the store has a payment method "Offline" with a code "OFFLINE"
And it has instructions "Account number: 0000 1111 2222 3333"
@ui
Scenario: Being informed about payment instructions on thank you page
@ui @api
Scenario: Being informed about payment instructions
Given I am a logged in customer
And I have product "PHP T-Shirt" in the cart
When I proceed selecting "Offline" payment method
And I confirm my order
Then I should see the thank you page
And I should be informed with "Offline" payment method instructions

View file

@ -553,6 +553,38 @@ final class CheckoutContext implements Context
);
}
/**
* @Then I should be informed with :paymentMethod payment method instructions
*/
public function iShouldBeInformedWithPaymentMethodInstructions(PaymentMethodInterface $paymentMethod): void
{
$response = $this->client->getLastResponse();
$payments = $this->responseChecker->getValue($response, 'payments');
Assert::notEmpty($payments, 'No payments found in response.');
$paymentMethodIri = $this->iriConverter->getIriFromItem($paymentMethod);
foreach ($payments as $payment) {
if ($payment['method'] !== $paymentMethodIri) {
continue;
}
$customRequest = $this->requestFactory->custom($payment['method'], HTTPRequest::METHOD_GET);
$paymentMethodResponse = $this->client->executeCustomRequest($customRequest);
Assert::same(
$this->responseChecker->getValue(
$paymentMethodResponse,
'instructions',
),
$paymentMethod->getInstructions(),
sprintf('Payment method instructions should be equal to %s', $paymentMethod->getInstructions()),
);
return;
}
throw new \Exception(sprintf('Payment method %s not found in response.', $paymentMethod->getName()));
}
/**
* @Then I should not be able to confirm order because products do not fit :shippingMethod requirements
*/