Skip to content

Commit

Permalink
[Api] Fix failing steps
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKasp committed Aug 3, 2020
1 parent 1533978 commit 4d279a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function __construct(
}

/**
* @Given I have proceeded selecting :shippingMetho shipping method
* @Given I have proceeded selecting :shippingMethod shipping method
* @When I proceed with :shippingMethodName shipping method
*/
public function iHaveProceededSelectingShippingMethod(ShippingMethodInterface $shippingMethod): void
public function iHaveProceededSelectingShippingMethod(?ShippingMethodInterface $shippingMethod): void
{
$this->iSelectShippingMethod($shippingMethod);
$this->selectShippingPage->nextStep();
Expand All @@ -55,9 +55,13 @@ public function iHaveProceededSelectingShippingMethod(ShippingMethodInterface $s
* @Given I have selected :shippingMethod shipping method
* @When I select :shippingMethod shipping method
*/
public function iSelectShippingMethod(ShippingMethodInterface $shippingMethod): void
public function iSelectShippingMethod(?ShippingMethodInterface $shippingMethod): void
{
$this->selectShippingPage->selectShippingMethod($shippingMethod->getName());
$shippingMethodName = 'Free';
if ($shippingMethod !== null) {
$shippingMethodName = $shippingMethod->getName();
}
$this->selectShippingPage->selectShippingMethod($shippingMethodName);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions src/Sylius/Behat/Context/Ui/Shop/CheckoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ public function __construct(
public function iWasAtTheCheckoutSummaryStep()
{
$this->addressingContext->iSpecifiedTheBillingAddress();
$this->iProceedOrderWithShippingMethodAndPayment('Free', 'Offline');
$this->iProceedOrderWithShippingMethodAndPayment(null, 'Offline');
}

/**
* @Given I chose :shippingMethodName shipping method
* @When I proceed selecting :shippingMethodName shipping method
* @Given I chose :shippingMethod shipping method
* @When I proceed selecting :shippingMethod shipping method
*/
public function iProceedSelectingShippingMethod($shippingMethodName)
public function iProceedSelectingShippingMethod(ShippingMethodInterface $shippingMethod): void
{
$this->iProceedSelectingBillingCountryAndShippingMethod(null, $shippingMethodName);
$this->iProceedSelectingBillingCountryAndShippingMethod(null, $shippingMethod);
}

/**
Expand All @@ -117,7 +117,7 @@ public function iProceedSelectingPaymentMethod($paymentMethodName)
* @Given I have proceeded order with :shippingMethod shipping method and :paymentMethodName payment
* @When I proceed with :shippingMethod shipping method and :paymentMethodName payment
*/
public function iProceedOrderWithShippingMethodAndPayment(ShippingMethodInterface $shippingMethod, $paymentMethodName)
public function iProceedOrderWithShippingMethodAndPayment(?ShippingMethodInterface $shippingMethod, $paymentMethodName)
{
$this->shippingContext->iHaveProceededSelectingShippingMethod($shippingMethod);
$this->paymentContext->iChoosePaymentMethod($paymentMethodName);
Expand All @@ -139,19 +139,19 @@ public function iProceedThroughCheckoutProcess(string $localeCode = 'en_US', ?st
/**
* @When /^I proceed selecting ("[^"]+" as billing country) with "([^"]+)" method$/
*/
public function iProceedSelectingBillingCountryAndShippingMethod(CountryInterface $shippingCountry = null, $shippingMethodName = null)
public function iProceedSelectingBillingCountryAndShippingMethod(CountryInterface $shippingCountry = null, ?ShippingMethodInterface $shippingMethod = null)
{
$this->addressingContext->iProceedSelectingBillingCountry($shippingCountry);
$this->shippingContext->iHaveProceededSelectingShippingMethod($shippingMethodName ?: 'Free');
$this->shippingContext->iHaveProceededSelectingShippingMethod($shippingMethod);
}

/**
* @When /^I change shipping method to "([^"]*)"$/
* @When I change shipping method to :shippingMethod
*/
public function iChangeShippingMethod($shippingMethodName)
public function iChangeShippingMethod(ShippingMethodInterface $shippingMethod): void
{
$this->paymentContext->iDecideToChangeMyShippingMethod();
$this->shippingContext->iHaveProceededSelectingShippingMethod($shippingMethodName);
$this->shippingContext->iHaveProceededSelectingShippingMethod($shippingMethod);
}

/**
Expand Down

0 comments on commit 4d279a3

Please sign in to comment.