[API] AddressOrderHandler refactored to use customer provider instead of logic duplication

This commit is contained in:
Łukasz Chruściel 2021-08-17 16:27:24 +02:00
parent 2c8755ec39
commit d911bfb019
No known key found for this signature in database
GPG key ID: 049A1D51AA3B039C
6 changed files with 81 additions and 132 deletions

View file

@ -42,6 +42,21 @@
}
```
1. The constructor of `Sylius\Bundle\ApiBundle\CommandHandler\Checkout\AddressOrderHandler` has been changed:
```diff
public function __construct(
OrderRepositoryInterface $orderRepository,
- CustomerRepositoryInterface $customerRepository,
- FactoryInterface $customerFactory,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
AddressMapperInterface $addressMapper
AddressMapperInterface $addressMapper,
+ CustomerProviderInterface $customerProvider
) {
```
1. The response schema for endpoint `GET /api/v2/shop/orders/{tokenValue}/shipments/{shipments}/methods` has been changed from:
```
@ -117,38 +132,38 @@
```
1. The service `Sylius\Bundle\ApiBundle\Converter\ItemIriToIdentifierConverter` has changed its name to `Sylius\Bundle\ApiBundle\Converter\IriToIdentifierConverter`
and its service definition from `Sylius\Bundle\ApiBundle\Converter\ItemIriToIdentifierConverter` to `Sylius\Bundle\ApiBundle\Converter\IriToIdentifierConverterInterface`
and its service definition from `Sylius\Bundle\ApiBundle\Converter\ItemIriToIdentifierConverter` to `Sylius\Bundle\ApiBundle\Converter\IriToIdentifierConverterInterface`
1. The service `Sylius\Bundle\ApiBundle\Serializer\CommandFieldItemIriToIdentifierDenormalizer` has changed its name to `Sylius\Bundle\ApiBundle\Serializer\CommandArgumentsDenormalizer`
and also its service definition.
and also its service definition.
1. Following namespaces has been changed:
* '\Sylius\Bundle\ApiBundle\CommandHandler\AddProductReviewHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Catalog\AddProductReviewHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\BlameCartHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Cart\BlameCartHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\RequestResetPasswordTokenHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\RequestResetPasswordTokenHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\ResendVerificationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\ResendVerificationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\ResetPasswordHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\ResetPasswordHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendAccountRegistrationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendAccountRegistrationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendAccountVerificationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendAccountVerificationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendOrderConfirmationHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendOrderConfirmationHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendResetPasswordEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendResetPasswordEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendShipmentConfirmationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendShipmentConfirmationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\VerifyCustomerAccountHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\VerifyCustomerAccountHandler'
* '\Sylius\Bundle\ApiBundle\Command\AddProductReview' => '\Sylius\Bundle\ApiBundle\Command\Catalog\AddProductReview'
* '\Sylius\Bundle\ApiBundle\Command\BlameCart' => '\Sylius\Bundle\ApiBundle\Command\Cart\BlameCart'
* '\Sylius\Bundle\ApiBundle\Command\RequestResetPasswordToken' => '\Sylius\Bundle\ApiBundle\Command\Account\RequestResetPasswordToken'
* '\Sylius\Bundle\ApiBundle\Command\ResendVerificationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\ResendVerificationEmail'
* '\Sylius\Bundle\ApiBundle\Command\ResetPassword' => '\Sylius\Bundle\ApiBundle\Command\Account\ResetPassword'
* '\Sylius\Bundle\ApiBundle\Command\SendAccountRegistrationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendAccountRegistrationEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendAccountVerificationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendAccountVerificationEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendOrderConfirmation' => '\Sylius\Bundle\ApiBundle\Command\Checkout\SendOrderConfirmation'
* '\Sylius\Bundle\ApiBundle\Command\SendResetPasswordEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendResetPasswordEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendShipmentConfirmationEmail' => '\Sylius\Bundle\ApiBundle\Command\Checkout\SendShipmentConfirmationEmail'
* '\Sylius\Bundle\ApiBundle\Command\VerifyCustomerAccount' => '\Sylius\Bundle\ApiBundle\Command\Account\VerifyCustomerAccount'
* `\Sylius\Bundle\ApiBundle\CommandHandler\ChangeShopUserPasswordHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Account\ChangeShopUserPasswordHandler`
* `\Sylius\Bundle\ApiBundle\CommandHandler\PickupCartHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Cart\PickupCartHandler`
* `\Sylius\Bundle\ApiBundle\CommandHandler\RegisterShopUserHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Account\RegisterShopUserHandler`
* `\Sylius\Bundle\ApiBundle\Command\ChangeShopUserPassword` => `\Sylius\Bundle\ApiBundle\Command\Account\ChangeShopUserPassword`
* `\Sylius\Bundle\ApiBundle\Command\RegisterShopUser` => `\Sylius\Bundle\ApiBundle\Command\Account\RegisterShopUser`
* `\Sylius\Bundle\ApiBundle\Doctrine\Filters\ExchangeRateFilter` => `\Sylius\Bundle\ApiBundle\Doctrine\Filter\ExchangeRateFilter`
* `\Sylius\Bundle\ApiBundle\Doctrine\Filters\TranslationOrderNameAndLocaleFilter` => `Sylius\Bundle\ApiBundle\Doctrine\Filter\TranslationOrderNameAndLocaleFilter`
* '\Sylius\Bundle\ApiBundle\CommandHandler\AddProductReviewHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Catalog\AddProductReviewHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\BlameCartHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Cart\BlameCartHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\RequestResetPasswordTokenHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\RequestResetPasswordTokenHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\ResendVerificationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\ResendVerificationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\ResetPasswordHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\ResetPasswordHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendAccountRegistrationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendAccountRegistrationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendAccountVerificationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendAccountVerificationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendOrderConfirmationHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendOrderConfirmationHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendResetPasswordEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\SendResetPasswordEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\SendShipmentConfirmationEmailHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Checkout\SendShipmentConfirmationEmailHandler'
* '\Sylius\Bundle\ApiBundle\CommandHandler\VerifyCustomerAccountHandler' => '\Sylius\Bundle\ApiBundle\CommandHandler\Account\VerifyCustomerAccountHandler'
* '\Sylius\Bundle\ApiBundle\Command\AddProductReview' => '\Sylius\Bundle\ApiBundle\Command\Catalog\AddProductReview'
* '\Sylius\Bundle\ApiBundle\Command\BlameCart' => '\Sylius\Bundle\ApiBundle\Command\Cart\BlameCart'
* '\Sylius\Bundle\ApiBundle\Command\RequestResetPasswordToken' => '\Sylius\Bundle\ApiBundle\Command\Account\RequestResetPasswordToken'
* '\Sylius\Bundle\ApiBundle\Command\ResendVerificationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\ResendVerificationEmail'
* '\Sylius\Bundle\ApiBundle\Command\ResetPassword' => '\Sylius\Bundle\ApiBundle\Command\Account\ResetPassword'
* '\Sylius\Bundle\ApiBundle\Command\SendAccountRegistrationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendAccountRegistrationEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendAccountVerificationEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendAccountVerificationEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendOrderConfirmation' => '\Sylius\Bundle\ApiBundle\Command\Checkout\SendOrderConfirmation'
* '\Sylius\Bundle\ApiBundle\Command\SendResetPasswordEmail' => '\Sylius\Bundle\ApiBundle\Command\Account\SendResetPasswordEmail'
* '\Sylius\Bundle\ApiBundle\Command\SendShipmentConfirmationEmail' => '\Sylius\Bundle\ApiBundle\Command\Checkout\SendShipmentConfirmationEmail'
* '\Sylius\Bundle\ApiBundle\Command\VerifyCustomerAccount' => '\Sylius\Bundle\ApiBundle\Command\Account\VerifyCustomerAccount'
* `\Sylius\Bundle\ApiBundle\CommandHandler\ChangeShopUserPasswordHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Account\ChangeShopUserPasswordHandler`
* `\Sylius\Bundle\ApiBundle\CommandHandler\PickupCartHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Cart\PickupCartHandler`
* `\Sylius\Bundle\ApiBundle\CommandHandler\RegisterShopUserHandler` => `\Sylius\Bundle\ApiBundle\CommandHandler\Account\RegisterShopUserHandler`
* `\Sylius\Bundle\ApiBundle\Command\ChangeShopUserPassword` => `\Sylius\Bundle\ApiBundle\Command\Account\ChangeShopUserPassword`
* `\Sylius\Bundle\ApiBundle\Command\RegisterShopUser` => `\Sylius\Bundle\ApiBundle\Command\Account\RegisterShopUser`
* `\Sylius\Bundle\ApiBundle\Doctrine\Filters\ExchangeRateFilter` => `\Sylius\Bundle\ApiBundle\Doctrine\Filter\ExchangeRateFilter`
* `\Sylius\Bundle\ApiBundle\Doctrine\Filters\TranslationOrderNameAndLocaleFilter` => `Sylius\Bundle\ApiBundle\Doctrine\Filter\TranslationOrderNameAndLocaleFilter`

View file

@ -17,13 +17,11 @@ use Doctrine\Persistence\ObjectManager;
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use Sylius\Bundle\ApiBundle\Command\Checkout\AddressOrder;
use Sylius\Bundle\ApiBundle\Mapper\AddressMapperInterface;
use Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\OrderCheckoutTransitions;
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Webmozart\Assert\Assert;
@ -33,12 +31,6 @@ final class AddressOrderHandler implements MessageHandlerInterface
/** @var OrderRepositoryInterface */
private $orderRepository;
/** @var CustomerRepositoryInterface */
private $customerRepository;
/** @var FactoryInterface */
private $customerFactory;
/** @var ObjectManager */
private $manager;
@ -48,20 +40,21 @@ final class AddressOrderHandler implements MessageHandlerInterface
/** @var AddressMapperInterface */
private $addressMapper;
/** @var CustomerProviderInterface */
private $customerProvider;
public function __construct(
OrderRepositoryInterface $orderRepository,
CustomerRepositoryInterface $customerRepository,
FactoryInterface $customerFactory,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
AddressMapperInterface $addressMapper
AddressMapperInterface $addressMapper,
CustomerProviderInterface $customerProvider
) {
$this->orderRepository = $orderRepository;
$this->customerRepository = $customerRepository;
$this->customerFactory = $customerFactory;
$this->manager = $manager;
$this->stateMachineFactory = $stateMachineFactory;
$this->addressMapper = $addressMapper;
$this->customerProvider = $customerProvider;
}
public function __invoke(AddressOrder $addressOrder): OrderInterface
@ -80,7 +73,9 @@ final class AddressOrderHandler implements MessageHandlerInterface
);
if (null === $order->getCustomer()) {
$order->setCustomer($this->provideCustomerByEmail($addressOrder->email));
Assert::notNull($addressOrder->email, sprintf('Visitor should provide an email.'));
$order->setCustomer($this->customerProvider->provide($addressOrder->email));
}
/** @var AddressInterface|null $billingAddress */
@ -108,19 +103,4 @@ final class AddressOrderHandler implements MessageHandlerInterface
return $order;
}
private function provideCustomerByEmail(?string $email): CustomerInterface
{
Assert::notNull($email, sprintf('Visitor should provide an email.'));
$customer = $this->customerRepository->findOneBy(['email' => $email]);
if (null === $customer) {
/** @var CustomerInterface $customer */
$customer = $this->customerFactory->createNew();
$customer->setEmail($email);
$this->manager->persist($customer);
}
return $customer;
}
}

View file

@ -57,11 +57,10 @@
<service id="Sylius\Bundle\ApiBundle\CommandHandler\Checkout\AddressOrderHandler">
<argument type="service" id="sylius.repository.order" />
<argument type="service" id="sylius.repository.customer" />
<argument type="service" id="sylius.factory.customer" />
<argument type="service" id="sylius.manager.customer" />
<argument type="service" id="sylius.manager.order" />
<argument type="service" id="sm.factory" />
<argument type="service" id="Sylius\Bundle\ApiBundle\Mapper\AddressMapperInterface" />
<argument type="service" id="Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface" />
<tag name="messenger.message_handler" bus="sylius.command_bus" />
<tag name="messenger.message_handler" bus="sylius_default.bus" />
</service>

View file

@ -16,6 +16,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<defaults public="true" />
<service id="Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface" class="Sylius\Bundle\ApiBundle\Provider\CustomerProvider">
<argument type="service" id="sylius.canonicalizer" />
<argument type="service" id="sylius.factory.customer" />

View file

@ -21,10 +21,9 @@ use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use Sylius\Bundle\ApiBundle\Command\Checkout\AddressOrder;
use Sylius\Bundle\ApiBundle\CommandHandler\Checkout\AddressOrderHandler;
use Sylius\Bundle\ApiBundle\Mapper\AddressMapperInterface;
use Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface;
use Sylius\Component\Core\Model\Address;
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@ -40,15 +39,12 @@ final class ChangeAddressOrderHandlerTest extends KernelTestCase
/** @var RepositoryInterface $addressRepository */
$addressRepository = $container->get('sylius.repository.address');
/** @var CustomerRepositoryInterface $customerRepository */
$customerRepository = $container->get('sylius.repository.customer');
/** @var CustomerProviderInterface $customerProvider */
$customerProvider = $container->get('Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface');
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $container->get('sylius.repository.order');
/** @var FactoryInterface $customerFactory */
$customerFactory = $container->get('sylius.factory.customer');
/** @var ObjectManager $manager */
$manager = $container->get('doctrine.orm.default_entity_manager');
@ -79,11 +75,10 @@ final class ChangeAddressOrderHandlerTest extends KernelTestCase
$addressOrderHandler = new AddressOrderHandler(
$orderRepository,
$customerRepository,
$customerFactory,
$manager,
$stateMachineFactory,
$addressMapper
$addressMapper,
$customerProvider
);
$newBillingAddress = $address = new Address();

View file

@ -20,6 +20,7 @@ use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use SM\StateMachine\StateMachineInterface;
use Sylius\Bundle\ApiBundle\Command\Checkout\AddressOrder;
use Sylius\Bundle\ApiBundle\Mapper\AddressMapperInterface;
use Sylius\Bundle\ApiBundle\Provider\CustomerProviderInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\OrderInterface;
@ -32,19 +33,17 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
{
function let(
OrderRepositoryInterface $orderRepository,
CustomerRepositoryInterface $customerRepository,
FactoryInterface $customerFactory,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
AddressMapperInterface $addressMapper
AddressMapperInterface $addressMapper,
CustomerProviderInterface $customerProvider
): void {
$this->beConstructedWith(
$orderRepository,
$customerRepository,
$customerFactory,
$manager,
$stateMachineFactory,
$addressMapper
$addressMapper,
$customerProvider
);
}
@ -79,7 +78,7 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
function it_handles_addressing_an_order_for_visitor(
OrderRepositoryInterface $orderRepository,
FactoryInterface $customerFactory,
CustomerProviderInterface $customerProvider,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
CustomerInterface $customer,
@ -99,9 +98,8 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
$order->getCustomer()->willReturn(null);
$customerFactory->createNew()->willReturn($customer);
$customer->setEmail('r2d2@droid.com')->shouldBeCalled();
$manager->persist($customer)->shouldBeCalled();
$customerProvider->provide('r2d2@droid.com')->willReturn($customer);
$order->setCustomer($customer)->shouldBeCalled();
$order->getShippingAddress()->willReturn(null);
$order->getBillingAddress()->willReturn(null);
@ -117,9 +115,9 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
$this($addressOrder);
}
function it_handles_addressing_an_order_for_logged_in_shop_user(
function it_handles_addressing_an_order_with_the_cutomer_already_assigned(
OrderRepositoryInterface $orderRepository,
FactoryInterface $customerFactory,
CustomerProviderInterface $customerProvider,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
CustomerInterface $customer,
@ -139,8 +137,9 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
$order->getCustomer()->willReturn($customer);
$customerFactory->createNew()->shouldNotBeCalled();
$customer->setEmail('r2d2@droid.com')->shouldNotBeCalled();
$customerProvider->provide(Argument::any())->shouldNotBeCalled();
$customer->setEmail(Argument::any())->shouldNotBeCalled();
$manager->persist($customer)->shouldNotBeCalled();
$order->setCustomer($customer)->shouldNotBeCalled();
@ -158,49 +157,9 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
$this($addressOrder);
}
function it_handles_addressing_an_order_for_not_logged_in_shop_user(
OrderRepositoryInterface $orderRepository,
CustomerRepositoryInterface $customerRepository,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
CustomerInterface $customer,
AddressInterface $billingAddress,
AddressInterface $shippingAddress,
OrderInterface $order,
StateMachineInterface $stateMachine
): void {
$addressOrder = new AddressOrder(
'r2d2@droid.com',
$billingAddress->getWrappedObject(),
$shippingAddress->getWrappedObject()
);
$addressOrder->setOrderTokenValue('ORDERTOKEN');
$orderRepository->findOneBy(['tokenValue' => 'ORDERTOKEN'])->willReturn($order);
$order->getCustomer()->willReturn(null);
$customerRepository->findOneBy(['email' => 'r2d2@droid.com'])->willReturn($customer);
$order->getCustomer()->shouldBeCalled();
$order->setCustomer($customer)->shouldBeCalled();
$order->getShippingAddress()->willReturn(null);
$order->getBillingAddress()->willReturn(null);
$order->setBillingAddress($billingAddress)->shouldBeCalled();
$order->setShippingAddress($shippingAddress)->shouldBeCalled();
$stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->willReturn($stateMachine);
$stateMachine->can(OrderCheckoutTransitions::TRANSITION_ADDRESS)->willReturn(true);
$stateMachine->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS)->shouldBeCalled();
$manager->persist($order)->shouldBeCalled();
$this($addressOrder);
}
function it_updates_order_address_based_on_data_form_new_order_address(
OrderRepositoryInterface $orderRepository,
FactoryInterface $customerFactory,
CustomerProviderInterface $customerProvider,
ObjectManager $manager,
StateMachineFactoryInterface $stateMachineFactory,
AddressMapperInterface $addressMapper,
@ -223,9 +182,8 @@ final class AddressOrderHandlerSpec extends ObjectBehavior
$order->getCustomer()->willReturn(null);
$customerFactory->createNew()->willReturn($customer);
$customer->setEmail('r2d2@droid.com')->shouldBeCalled();
$manager->persist($customer)->shouldBeCalled();
$customerProvider->provide('r2d2@droid.com')->willReturn($customer);
$order->setCustomer($customer)->shouldBeCalled();
$order->getBillingAddress()->willReturn($oldBillingAddress);
$order->getShippingAddress()->willReturn($oldShippingAddress);