diff --git a/features/checkout/receiving_confirmation_email_after_completing_checkout.feature b/features/checkout/receiving_confirmation_email_after_completing_checkout.feature
index 5c9e0d507f63..c8972881550a 100644
--- a/features/checkout/receiving_confirmation_email_after_completing_checkout.feature
+++ b/features/checkout/receiving_confirmation_email_after_completing_checkout.feature
@@ -19,7 +19,7 @@ Feature: Receiving confirmation email after finalizing checkout
When I confirm my order
Then an email with the summary of order placed by "john@example.com" should be sent to him
- @ui @email
+ @ui @email @api
Scenario: Receiving confirmation email after finalizing checkout in different locale than the default one
Given I have product "Sig Sauer P226" in the cart
And I have proceeded through checkout process in the "Polish (Poland)" locale with email "john@example.com"
diff --git a/src/Sylius/Behat/Context/Setup/CheckoutContext.php b/src/Sylius/Behat/Context/Setup/CheckoutContext.php
index f765c7c492cd..f908e50f26e6 100644
--- a/src/Sylius/Behat/Context/Setup/CheckoutContext.php
+++ b/src/Sylius/Behat/Context/Setup/CheckoutContext.php
@@ -19,7 +19,6 @@
use Sylius\Bundle\ApiBundle\Command\Checkout\ChoosePaymentMethod;
use Sylius\Bundle\ApiBundle\Command\Checkout\ChooseShippingMethod;
use Sylius\Component\Core\Model\AddressInterface;
-<<<<<<< HEAD
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Model\ShipmentInterface;
@@ -62,28 +61,30 @@ public function __construct(
$this->paymentMethodRepository = $paymentMethodRepository;
$this->commandBus = $commandBus;
$this->addressFactory = $addressFactory;
-=======
-use Sylius\Component\Core\Model\PaymentMethodInterface;
-use Sylius\Component\Core\Model\ShippingMethodInterface;
-use Symfony\Component\Messenger\MessageBusInterface;
+ $this->sharedStorage = $sharedStorage;
+ }
-final class CheckoutContext implements Context
-{
- /** @var MessageBusInterface */
- private $commandBus;
+ /**
+ * @Given I have proceeded through checkout process in the :localeCode locale with email :email
+ */
+ public function iHaveProceededThroughCheckoutProcessInTheLocaleWithEmail(string $localeCode, string $email)
+ {
+ $cartToken = $this->sharedStorage->get('cart_token');
- /** @var SharedStorageInterface */
- private $sharedStorage;
+ /** @var OrderInterface|null $cart */
+ $cart = $this->orderRepository->findCartByTokenValue($cartToken);
+ Assert::notNull($cart);
- public function __construct(MessageBusInterface $commandBus, SharedStorageInterface $sharedStorage)
- {
- $this->commandBus = $commandBus;
->>>>>>> 7f2cb5abed... [API] Order confirmation email sending
- $this->sharedStorage = $sharedStorage;
+ $cart->setLocaleCode($localeCode);
+
+ $command = new AddressOrder($email, $this->getDefaultAddress());
+ $command->setOrderTokenValue($cartToken);
+ $this->commandBus->dispatch($command);
+
+ $this->completeCheckout($cart);
}
/**
-<<<<<<< HEAD
* @Given I have proceeded through checkout process
*/
public function iHaveProceededThroughCheckoutProcess(): void
@@ -94,8 +95,18 @@ public function iHaveProceededThroughCheckoutProcess(): void
$cart = $this->orderRepository->findCartByTokenValue($cartToken);
Assert::notNull($cart);
+ $command = new AddressOrder('rich@sylius.com', $this->getDefaultAddress());
+ $command->setOrderTokenValue($cartToken);
+ $this->commandBus->dispatch($command);
+
+ $this->completeCheckout($cart);
+ }
+
+ private function getDefaultAddress(): AddressInterface
+ {
/** @var AddressInterface $address */
$address = $this->addressFactory->createNew();
+
$address->setCity('New York');
$address->setStreet('Wall Street');
$address->setPostcode('00-001');
@@ -103,53 +114,27 @@ public function iHaveProceededThroughCheckoutProcess(): void
$address->setFirstName('Richy');
$address->setLastName('Rich');
- $command = new AddressOrder('rich@sylius.com', $address);
- $command->setOrderTokenValue($cartToken);
- $this->commandBus->dispatch($command);
+ return $address;
+ }
+ private function completeCheckout(OrderInterface $order): void
+ {
$command = new ChooseShippingMethod($this->shippingMethodRepository->findOneBy([])->getCode());
- $command->setOrderTokenValue($cartToken);
+ $command->setOrderTokenValue($order->getTokenValue());
/** @var ShipmentInterface $shipment */
- $shipment = $cart->getShipments()->first();
+ $shipment = $order->getShipments()->first();
$command->setSubresourceId((string) $shipment->getId());
$this->commandBus->dispatch($command);
$command = new ChoosePaymentMethod($this->paymentMethodRepository->findOneBy([])->getCode());
- $command->setOrderTokenValue($cartToken);
+ $command->setOrderTokenValue($order->getTokenValue());
/** @var PaymentInterface $payment */
- $payment = $cart->getPayments()->first();
+ $payment = $order->getPayments()->first();
$command->setSubresourceId((string) $payment->getId());
$this->commandBus->dispatch($command);
-=======
- * @Given /^I have completed addressing step with email "([^"]+)" and ("[^"]+" based billing address)$/
- */
- public function iHaveCompletedAddressingStepWithEmail(string $email, AddressInterface $address): void
- {
- $addressOrder = new AddressOrder($email, $address);
-
- $addressOrder->setOrderTokenValue($this->sharedStorage->get('cart_token'));
-
- $this->commandBus->dispatch($addressOrder);
- }
-
- /**
- * @Given I have proceeded order with :shippingMethod shipping method and :paymentMethod payment
- */
- public function iProceedOrderWithShippingMethodAndPayment(ShippingMethodInterface $shippingMethod, PaymentMethodInterface $paymentMethod): void
- {
- $cartToken = $this->sharedStorage->get('cart_token');
- $chooseShippingMethod = new ChooseShippingMethod(0, $shippingMethod->getCode());
- $choosePaymentMethod = new ChoosePaymentMethod(0, $paymentMethod->getCode());
-
- $chooseShippingMethod->setOrderTokenValue($cartToken);
- $choosePaymentMethod->setOrderTokenValue($cartToken);
-
- $this->commandBus->dispatch($chooseShippingMethod);
- $this->commandBus->dispatch($choosePaymentMethod);
->>>>>>> 7f2cb5abed... [API] Order confirmation email sending
}
}
diff --git a/src/Sylius/Behat/Resources/config/services/contexts/setup.xml b/src/Sylius/Behat/Resources/config/services/contexts/setup.xml
index 7cb46240a3d2..badc19787e90 100644
--- a/src/Sylius/Behat/Resources/config/services/contexts/setup.xml
+++ b/src/Sylius/Behat/Resources/config/services/contexts/setup.xml
@@ -46,11 +46,6 @@
-
-
-
-
-
diff --git a/src/Sylius/Bundle/ApiBundle/composer.json b/src/Sylius/Bundle/ApiBundle/composer.json
index 136f3a244ab2..9ac7c1cf9d6c 100644
--- a/src/Sylius/Bundle/ApiBundle/composer.json
+++ b/src/Sylius/Bundle/ApiBundle/composer.json
@@ -25,7 +25,7 @@
"require": {
"php": "^7.3",
"api-platform/core": "^2.5",
- "sylius/core-bundle": "^1.7",
+ "sylius/core-bundle": "dev-master",
"symfony/messenger": "^4.4"
},
"require-dev": {