Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKasp committed Feb 23, 2022
1 parent 176c78f commit 01b73eb
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 46 deletions.
5 changes: 5 additions & 0 deletions UPGRADE-API-1.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ Here is how the response looks like:
1. Endpoints `/shop/orders/{tokenValue}/payments/{payments}/methods`, `/shop/payments/{id}/methods` has been removed and replaced by `/shop/payment-methods` with filter `paymentId` and `tokenValue`
`/shop/payment-methods` returns all enable payment methods if filters are not set, payment methods related to payment if filters are filled or empty response if filters ale filled with invalid data.
1. Service `Sylius\Bundle\ApiBundle\DataProvider/CartPaymentMethodsSubresourceDataProvider` has been removed and logic was replaced by `Sylius\Bundle\ApiBundle\DataProvider\PaymentMethodsCollectionDataProvider`
1. The `GET` `api/v2/shop/orders/{tokenValue}/payments/{payments}/methods` and `api/v2/shop/payments/{id}/methods` endpoints have been removed and changed into collection request with 2 parameters `api/v2/shop/payment-methods?paymentId={id}&orderToken={token}`.
Now when we do not provide parameters in response it returns all available `paymentMethods` in channel.
Wrong parameters otherwise cause empty array `[]` in response and correct parameters return `paymentMethods` available for your `payment`.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Feature: Viewing available payment methods based on current channel
And the store has a zone "World"
And the store ships to "United States"
And this zone has the "United States" country member
And the store allows paying "Bank of America" in "United States" channel
And the store allows paying "Bank of Poland" in "Poland" channel
And the store allows paying with "Bank of America" in "United States" channel
And the store allows paying with "Bank of Poland" in "Poland" channel
And the store allows paying offline for all channels
And the store allows paying "Bank of Universe"
And this payment method has been disabled
Expand All @@ -20,9 +20,9 @@ Feature: Viewing available payment methods based on current channel
And the store ships everywhere for free for all channels

@ui @api
Scenario: Seeing payment methods that are available in channel as an logged in customer
Scenario: Seeing payment methods that are available in channel as a logged in customer
Given I am a logged in customer
And I view shop on "United States" channel
And I am in the "United States" channel
And I have product "PHP T-Shirt" in the cart
When I complete addressing step with "United States" based billing address
And I complete the shipping step with first shipping method
Expand All @@ -33,7 +33,7 @@ Feature: Viewing available payment methods based on current channel
@api @ui
Scenario: Seeing shipping methods that are available in another channel as an logged in customer
Given I am a logged in customer
And I view shop on "Poland" channel
And I am in the "Poland" channel
And I have product "PHP T-Shirt" in the cart
When I complete addressing step with "United States" based billing address
And I complete the shipping step with first shipping method
Expand All @@ -43,7 +43,7 @@ Feature: Viewing available payment methods based on current channel

@ui @api
Scenario: Seeing payment methods that are available in channel as a guest
Given I view shop on "United States" channel
Given I am in the "United States" channel
And I have product "PHP T-Shirt" in the cart
When I complete addressing step with email "john@example.com" and "United States" based billing address
And I complete the shipping step with first shipping method
Expand All @@ -53,7 +53,7 @@ Feature: Viewing available payment methods based on current channel

@ui @api
Scenario: Seeing shipping methods that are available in another channel as a guest
Given I view shop on "Poland" channel
Given I am in the "Poland" channel
And I have product "PHP T-Shirt" in the cart
When I complete addressing step with email "john@example.com" and "United States" based billing address
And I complete the shipping step with first shipping method
Expand Down
16 changes: 8 additions & 8 deletions src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,25 +612,25 @@ public function iShouldBeAbleToSelectPaymentMethod(string $paymentMethodName): v
/**
* @Then I should see :firstPaymentMethodName and :secondPaymentMethodName payment methods
*/
public function iShouldSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void
public function iShouldSeePaymentMethods(string ...$paymentMethodsNames): void
{
$paymentMethods = $this->getPossiblePaymentMethods();

Assert::inArray($firstPaymentMethodName, array_column($paymentMethods, 'name'));

Assert::inArray($secondPaymentMethodName, array_column($paymentMethods, 'name'));
foreach ($paymentMethodsNames as $paymentMethodName) {
Assert::inArray($paymentMethodName, array_column($paymentMethods, 'name'));
}
}

/**
* @Then I should not see :firstPaymentMethodName and :secondPaymentMethodName payment methods
*/
public function iShouldNotSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void
public function iShouldNotSeePaymentMethods(string ...$paymentMethodsNames): void
{
$paymentMethods = $this->getPossiblePaymentMethods();

Assert::false(in_array($firstPaymentMethodName, array_column($paymentMethods, 'name'), true));

Assert::false(in_array($secondPaymentMethodName, array_column($paymentMethods, 'name'), true));
foreach ($paymentMethodsNames as $paymentMethodName) {
Assert::false(in_array($paymentMethodName, array_column($paymentMethods, 'name'), true));
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Setup/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function channelDoesNotDefineOperatingCountries(ChannelInterface $channel
* @Given /^I changed (?:|back )my current (channel to "([^"]+)")$/
* @When /^I change (?:|back )my current (channel to "([^"]+)")$/
* @When customer view shop on :channel channel
* @When I view shop on :channel channel
* @When I am in the :channel channel
*/
public function iChangeMyCurrentChannelTo(ChannelInterface $channel): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Setup/PaymentContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public function thePaymentMethodRequiresAuthorizationBeforeCapturing(PaymentMeth
}

/**
* @Given the store allows paying :paymentMethodName in :channel channel
* @Given the store allows paying with :paymentMethodName in :channel channel
*/
public function theStoreAllowsPayingInChannel(string $paymentMethodName, ChannelInterface $channel): void
public function theStoreAllowsPayingWithInChannel(string $paymentMethodName, ChannelInterface $channel): void
{
$paymentMethod = $this->createPaymentMethod(
$paymentMethodName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,26 @@ public function iShouldNotBeAbleToProceedCheckoutPaymentStep(): void
/**
* @Then I should see :firstPaymentMethodName and :secondPaymentMethodName payment methods
*/
public function iShouldSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void
public function iShouldSeeAndPaymentMethods(string ...$paymentMethodsNames): void
{
Assert::true(
$this->selectPaymentPage->hasPaymentMethod($firstPaymentMethodName),
sprintf('There is no %s payment method', $firstPaymentMethodName)
);

Assert::true(
$this->selectPaymentPage->hasPaymentMethod($secondPaymentMethodName),
sprintf('There is no %s payment method', $secondPaymentMethodName)
);
foreach ($paymentMethodsNames as $paymentMethodName) {
Assert::true(
$this->selectPaymentPage->hasPaymentMethod($paymentMethodName),
sprintf('There is no %s payment method', $paymentMethodName)
);
}
}

/**
* @Then I should not see :firstPaymentMethodName and :secondPaymentMethodName payment methods
*/
public function iShouldNotSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void
public function iShouldNotSeeAndPaymentMethods(string ...$paymentMethodsNames): void
{
Assert::false(
$this->selectPaymentPage->hasPaymentMethod($firstPaymentMethodName),
sprintf('There is %s payment method', $firstPaymentMethodName)
);

Assert::false(
$this->selectPaymentPage->hasPaymentMethod($secondPaymentMethodName),
sprintf('There is %s payment method', $secondPaymentMethodName)
);
foreach ($paymentMethodsNames as $paymentMethodName) {
Assert::false(
$this->selectPaymentPage->hasPaymentMethod($paymentMethodName),
sprintf('There is %s payment method', $paymentMethodName)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@
<service id="sylius.behat.context.api.shop.checkout" class="Sylius\Behat\Context\Api\Shop\CheckoutContext">
<argument type="service" id="sylius.behat.api_platform_client.shop.order" />
<argument type="service" id="sylius.behat.api_platform_client.shop.address" />
<<<<<<< HEAD
<argument type="service" id="sylius.behat.api_platform_client.shop.shipping_methods" />
=======
<argument type="service" id="sylius.behat.api_platform_client.shop.payment_method" />
>>>>>>> 5d12d48b14 (add missing units and minor fixes)
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="sylius.repository.shipping_method" />
<argument type="service" id="sylius.repository.order" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public function getCollection(string $resourceClass, string $operationName = nul

$parameters = $context['filters'];

if (!array_key_exists('tokenValue', $parameters)) {
return [];
}

if (!array_key_exists('paymentId', $parameters)) {
if (!array_key_exists('tokenValue', $parameters) || !array_key_exists('paymentId', $parameters) ) {
return [];
}

Expand Down

0 comments on commit 01b73eb

Please sign in to comment.