128 private $quoteIdMock;
133 private $addressRepositoryMock;
138 private $quoteFactoryMock;
145 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
147 $this->quoteValidator = $this->createMock(\
Magento\
Quote\Model\QuoteValidator::class);
148 $this->eventManager = $this->getMockForAbstractClass(\
Magento\Framework\Event\ManagerInterface::class);
149 $this->orderFactory = $this->createPartialMock(
150 \
Magento\Sales\Api\Data\OrderInterfaceFactory::class,
151 [
'create',
'populate']
157 $this->orderManagement = $this->createMock(\
Magento\Sales\Api\OrderManagementInterface::class);
158 $this->customerManagement = $this->createMock(\
Magento\
Quote\Model\CustomerManagement::class);
159 $this->quoteRepositoryMock = $this->createMock(\
Magento\
Quote\Api\CartRepositoryInterface::class);
161 $this->userContextMock = $this->createMock(\
Magento\Authorization\Model\UserContextInterface::class);
162 $this->customerRepositoryMock = $this->createPartialMock(
163 \
Magento\Customer\Api\CustomerRepositoryInterface::class,
164 [
'create',
'save',
'get',
'getById',
'getList',
'delete',
'deleteById']
166 $this->customerFactoryMock = $this->createPartialMock(
167 \
Magento\Customer\Model\CustomerFactory::class,
170 $this->storeManagerMock = $this->getMockForAbstractClass(
177 [
'getStore',
'getStoreId']
180 $this->quoteMock = $this->createPartialMock(\
Magento\
Quote\Model\Quote::class, [
187 'setCustomerIsGuest',
188 'setCustomerGroupId',
193 $this->quoteAddressFactory = $this->createPartialMock(
198 $this->dataObjectHelperMock = $this->createMock(\
Magento\Framework\Api\DataObjectHelper::class);
199 $this->checkoutSessionMock = $this->createPartialMock(
200 \
Magento\Checkout\Model\Session::class,
201 [
'setLastQuoteId',
'setLastSuccessQuoteId',
'setLastOrderId',
'setLastRealOrderId',
'setLastOrderStatus']
203 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
204 $this->accountManagementMock = $this->createMock(\
Magento\Customer\Api\AccountManagementInterface::class);
206 $this->quoteFactoryMock = $this->createPartialMock(\
Magento\
Quote\Model\QuoteFactory::class, [
'create']);
207 $this->addressRepositoryMock = $this->getMockBuilder(\
Magento\Customer\Api\AddressRepositoryInterface::class)
208 ->getMockForAbstractClass();
213 'eventManager' => $this->eventManager,
214 'quoteValidator' => $this->quoteValidator,
215 'orderFactory' => $this->orderFactory,
216 'orderManagement' => $this->orderManagement,
217 'customerManagement' => $this->customerManagement,
218 'quoteAddressToOrder' => $this->quoteAddressToOrder,
219 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress,
220 'quoteItemToOrderItem' => $this->quoteItemToOrderItem,
221 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment,
222 'userContext' => $this->userContextMock,
223 'quoteRepository' => $this->quoteRepositoryMock,
224 'customerRepository' => $this->customerRepositoryMock,
225 'customerModelFactory' => $this->customerFactoryMock,
226 'quoteAddressFactory' => $this->quoteAddressFactory,
227 'dataObjectHelper' => $this->dataObjectHelperMock,
228 'storeManager' => $this->storeManagerMock,
229 'checkoutSession' => $this->checkoutSessionMock,
230 'customerSession' => $this->customerSessionMock,
231 'accountManagement' => $this->accountManagementMock,
232 'quoteFactory' => $this->quoteFactoryMock,
233 'addressRepository' => $this->addressRepositoryMock
238 $this->quoteIdMock = $this->createMock(\
Magento\
Quote\Model\QuoteIdMask::class);
239 $quoteIdFactoryMock = $this->createPartialMock(\
Magento\
Quote\Model\QuoteIdMaskFactory::class, [
'create']);
240 $this->
setPropertyValue($this->model,
'quoteIdMaskFactory', $quoteIdFactoryMock);
249 $quoteAddress = $this->createPartialMock(
251 [
'setCollectShippingRates']
253 $quoteAddress->expects($this->once())->method(
'setCollectShippingRates')->with(
true);
255 $quoteMock->expects($this->any())->method(
'setBillingAddress')->with($quoteAddress)->willReturnSelf();
256 $quoteMock->expects($this->any())->method(
'setShippingAddress')->with($quoteAddress)->willReturnSelf();
257 $quoteMock->expects($this->any())->method(
'getShippingAddress')->willReturn($quoteAddress);
259 $this->quoteAddressFactory->expects($this->any())->method(
'create')->willReturn($quoteAddress);
261 $this->quoteFactoryMock->expects($this->once())->method(
'create')->willReturn(
$quoteMock);
264 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quoteMock);
267 $this->storeManagerMock->expects($this->once())->method(
'getStore')->willReturnSelf();
268 $this->storeManagerMock->expects($this->once())->method(
'getStoreId')->willReturn(
$storeId);
270 $this->assertEquals(
$quoteId, $this->model->createEmptyCart());
281 $this->quoteRepositoryMock
282 ->expects($this->once())
283 ->method(
'getActiveForCustomer')
287 $this->quoteFactoryMock->expects($this->once())->method(
'create')->willReturn(
$quoteMock);
289 $quoteMock->expects($this->any())->method(
'setCustomerIsGuest')->with(0);
291 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quoteMock);
294 $this->storeManagerMock->expects($this->once())->method(
'getStore')->willReturnSelf();
295 $this->storeManagerMock->expects($this->once())->method(
'getStoreId')->willReturn(
$storeId);
297 $this->assertEquals(
$quoteId, $this->model->createEmptyCartForCustomer($userId));
307 $this->quoteRepositoryMock
308 ->expects($this->once())
309 ->method(
'getActiveForCustomer')
312 $this->quoteFactoryMock->expects($this->never())->method(
'create')->willReturn(
$quoteMock);
313 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quoteMock);
315 $this->storeManagerMock->expects($this->once())->method(
'getStore')->willReturnSelf();
316 $this->storeManagerMock->expects($this->once())->method(
'getStoreId')->willReturn(
$storeId);
318 $this->model->createEmptyCartForCustomer($userId);
332 $customerMock = $this->createMock(\
Magento\Customer\Api\Data\CustomerInterface::class);
334 $this->quoteRepositoryMock
335 ->expects($this->once())
336 ->method(
'getActive')
340 $this->customerRepositoryMock
341 ->expects($this->once())
344 ->willReturn($customerMock);
346 $customerModelMock = $this->createPartialMock(
347 \
Magento\Customer\Model\Customer::class,
348 [
'load',
'getSharedStoreIds']
350 $this->customerFactoryMock->expects($this->once())->method(
'create')->willReturn($customerModelMock);
352 ->expects($this->once())
358 ->expects($this->once())
359 ->method(
'getSharedStoreIds')
377 [
'getCustomerId',
'setCustomer',
'setCustomerIsGuest']
379 $customerMock = $this->createMock(\
Magento\Customer\Api\Data\CustomerInterface::class);
381 $this->quoteRepositoryMock
382 ->expects($this->once())
383 ->method(
'getActive')
387 $this->customerRepositoryMock
388 ->expects($this->once())
391 ->willReturn($customerMock);
393 $customerModelMock = $this->createPartialMock(
394 \
Magento\Customer\Model\Customer::class,
395 [
'load',
'getSharedStoreIds']
397 $this->customerFactoryMock->expects($this->once())->method(
'create')->willReturn($customerModelMock);
399 ->expects($this->once())
405 ->expects($this->once())
406 ->method(
'getSharedStoreIds')
407 ->willReturn([
$storeId,
'some store value']);
409 $quoteMock->expects($this->once())->method(
'getCustomerId')->willReturn(753);
425 [
'getCustomerId',
'setCustomer',
'setCustomerIsGuest']
427 $customerMock = $this->createMock(\
Magento\Customer\Api\Data\CustomerInterface::class);
429 $this->quoteRepositoryMock
430 ->expects($this->once())
431 ->method(
'getActive')
435 $this->customerRepositoryMock
436 ->expects($this->once())
439 ->willReturn($customerMock);
441 $customerModelMock = $this->createPartialMock(
442 \
Magento\Customer\Model\Customer::class,
443 [
'load',
'getSharedStoreIds']
445 $this->customerFactoryMock->expects($this->once())->method(
'create')->willReturn($customerModelMock);
447 ->expects($this->once())
453 ->expects($this->once())
454 ->method(
'getSharedStoreIds')
455 ->willReturn([
$storeId,
'some store value']);
457 $quoteMock->expects($this->once())->method(
'getCustomerId')->willReturn(
null);
459 $this->quoteRepositoryMock
460 ->expects($this->once())
461 ->method(
'getForCustomer')
466 $this->expectExceptionMessage(
467 "The customer can't be assigned to the cart because the customer already has an active cart." 478 ->expects($this->once())
480 ->willReturn($this->quoteIdMock);
481 $this->quoteIdMock->expects($this->once())->method(
'load')->with(
$cartId,
'quote_id')->willReturnSelf();
482 $this->quoteIdMock->expects($this->once())->method(
'getId')->willReturn(10);
483 $this->quoteIdMock->expects($this->once())->method(
'delete');
486 [
'getCustomerId',
'setCustomer',
'setCustomerIsGuest']
488 $customerMock = $this->createMock(\
Magento\Customer\Api\Data\CustomerInterface::class);
490 $this->quoteRepositoryMock
491 ->expects($this->once())
492 ->method(
'getActive')
496 $this->customerRepositoryMock
497 ->expects($this->once())
500 ->willReturn($customerMock);
502 $customerModelMock = $this->createPartialMock(
503 \
Magento\Customer\Model\Customer::class,
504 [
'load',
'getSharedStoreIds']
506 $this->customerFactoryMock->expects($this->once())->method(
'create')->willReturn($customerModelMock);
508 ->expects($this->once())
514 ->expects($this->once())
515 ->method(
'getSharedStoreIds')
516 ->willReturn([
$storeId,
'some store value']);
518 $quoteMock->expects($this->once())->method(
'getCustomerId')->willReturn(
null);
520 $this->quoteRepositoryMock
521 ->expects($this->once())
522 ->method(
'getForCustomer')
526 $quoteMock->expects($this->once())->method(
'setCustomer')->with($customerMock);
527 $quoteMock->expects($this->once())->method(
'setCustomerIsGuest')->with(0);
529 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quoteMock);
545 $baseOrder = $this->createMock(\
Magento\Sales\Api\Data\OrderInterface::class);
546 $convertedBilling = $this->createPartialMockForAbstractClass(OrderAddressInterface::class, [
'setData']);
547 $convertedShipping = $this->createPartialMockForAbstractClass(OrderAddressInterface::class, [
'setData']);
548 $convertedPayment = $this->createMock(\
Magento\Sales\Api\Data\OrderPaymentInterface::class);
549 $convertedQuoteItem = $this->createMock(\
Magento\Sales\Api\Data\OrderItemInterface::class);
551 $addresses = [$convertedShipping, $convertedBilling];
553 $convertedItems = [$convertedQuoteItem];
566 $this->quoteValidator->expects($this->once())->method(
'validateBeforeSubmit')->with(
$quote);
567 $this->quoteAddressToOrder->expects($this->once())
570 ->willReturn($baseOrder);
571 $this->quoteAddressToOrderAddress->expects($this->at(0))
576 'address_type' =>
'shipping',
577 'email' =>
'customer@example.com' 580 ->willReturn($convertedShipping);
581 $this->quoteAddressToOrderAddress->expects($this->at(1))
586 'address_type' =>
'billing',
587 'email' =>
'customer@example.com' 590 ->willReturn($convertedBilling);
591 $billingAddress->expects($this->once())->method(
'getId')->willReturn(4);
592 $convertedBilling->expects($this->once())->method(
'setData')->with(
'quote_address_id', 4);
594 $this->quoteItemToOrderItem->expects($this->once())->method(
'convert')
596 ->willReturn($convertedQuoteItem);
597 $this->quotePaymentToOrderPayment->expects($this->once())->method(
'convert')->with(
$payment)
598 ->willReturn($convertedPayment);
599 $shippingAddress->expects($this->once())->method(
'getShippingMethod')->willReturn(
'free');
601 $convertedShipping->expects($this->once())->method(
'setData')->with(
'quote_address_id', 5);
612 $this->orderManagement->expects($this->once())
616 $this->eventManager->expects($this->at(0))
618 ->with(
'sales_model_service_quote_submit_before', [
'order' =>
$order,
'quote' =>
$quote]);
619 $this->eventManager->expects($this->at(1))
621 ->with(
'sales_model_service_quote_submit_success', [
'order' =>
$order,
'quote' =>
$quote]);
622 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quote);
623 $this->assertEquals(
$order, $this->model->submit(
$quote, $orderData));
626 public function testPlaceOrderIfCustomerIsGuest()
630 $orderIncrementId = 100003332;
632 $email =
'email@mail.com';
634 $this->quoteRepositoryMock->expects($this->once())
635 ->method(
'getActive')
637 ->willReturn($this->quoteMock);
639 $this->quoteMock->expects($this->once())
640 ->method(
'getCheckoutMethod')
641 ->willReturn(\
Magento\Checkout\Model\
Type\Onepage::METHOD_GUEST);
642 $this->quoteMock->expects($this->once())->method(
'setCustomerId')->with(
null)->willReturnSelf();
643 $this->quoteMock->expects($this->once())->method(
'setCustomerEmail')->with(
$email)->willReturnSelf();
645 $addressMock = $this->createPartialMock(\
Magento\
Quote\Model\
Quote\Address::class, [
'getEmail']);
646 $addressMock->expects($this->once())->method(
'getEmail')->willReturn(
$email);
647 $this->quoteMock->expects($this->once())->method(
'getBillingAddress')->with()->willReturn($addressMock);
649 $this->quoteMock->expects($this->once())->method(
'setCustomerIsGuest')->with(
true)->willReturnSelf();
650 $this->quoteMock->expects($this->once())
651 ->method(
'setCustomerGroupId')
652 ->with(\
Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID);
656 ->setMethods([
'submit'])
657 ->setConstructorArgs(
659 'eventManager' => $this->eventManager,
660 'quoteValidator' => $this->quoteValidator,
661 'orderFactory' => $this->orderFactory,
662 'orderManagement' => $this->orderManagement,
663 'customerManagement' => $this->customerManagement,
664 'quoteAddressToOrder' => $this->quoteAddressToOrder,
665 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress,
666 'quoteItemToOrderItem' => $this->quoteItemToOrderItem,
667 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment,
668 'userContext' => $this->userContextMock,
669 'quoteRepository' => $this->quoteRepositoryMock,
670 'customerRepository' => $this->customerRepositoryMock,
671 'customerModelFactory' => $this->customerFactoryMock,
672 'quoteAddressFactory' => $this->quoteAddressFactory,
673 'dataObjectHelper' => $this->dataObjectHelperMock,
674 'storeManager' => $this->storeManagerMock,
675 'checkoutSession' => $this->checkoutSessionMock,
676 'customerSession' => $this->customerSessionMock,
677 'accountManagement' => $this->accountManagementMock,
678 'quoteFactory' => $this->quoteFactoryMock
683 $orderMock = $this->createPartialMock(
684 \
Magento\Sales\Model\Order::class,
685 [
'getId',
'getIncrementId',
'getStatus']
687 $service->expects($this->once())->method(
'submit')->willReturn($orderMock);
689 $this->quoteMock->expects($this->atLeastOnce())->method(
'getId')->willReturn(
$cartId);
691 $orderMock->expects($this->atLeastOnce())->method(
'getId')->willReturn($orderId);
692 $orderMock->expects($this->atLeastOnce())->method(
'getIncrementId')->willReturn($orderIncrementId);
693 $orderMock->expects($this->atLeastOnce())->method(
'getStatus')->willReturn(
$orderStatus);
695 $this->checkoutSessionMock->expects($this->once())->method(
'setLastQuoteId')->with(
$cartId);
696 $this->checkoutSessionMock->expects($this->once())->method(
'setLastSuccessQuoteId')->with(
$cartId);
697 $this->checkoutSessionMock->expects($this->once())->method(
'setLastOrderId')->with($orderId);
698 $this->checkoutSessionMock->expects($this->once())->method(
'setLastRealOrderId')->with($orderIncrementId);
699 $this->checkoutSessionMock->expects($this->once())->method(
'setLastOrderStatus')->with(
$orderStatus);
704 public function testPlaceOrder()
708 $orderIncrementId = 100003332;
712 $service = $this->getMockBuilder(\
Magento\Quote\Model\QuoteManagement::class)
713 ->setMethods([
'submit'])
714 ->setConstructorArgs(
716 'eventManager' => $this->eventManager,
717 'quoteValidator' => $this->quoteValidator,
718 'orderFactory' => $this->orderFactory,
719 'orderManagement' => $this->orderManagement,
720 'customerManagement' => $this->customerManagement,
721 'quoteAddressToOrder' => $this->quoteAddressToOrder,
722 'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress,
723 'quoteItemToOrderItem' => $this->quoteItemToOrderItem,
724 'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment,
725 'userContext' => $this->userContextMock,
726 'quoteRepository' => $this->quoteRepositoryMock,
727 'customerRepository' => $this->customerRepositoryMock,
728 'customerModelFactory' => $this->customerFactoryMock,
729 'quoteAddressFactory' => $this->quoteAddressFactory,
730 'dataObjectHelper' => $this->dataObjectHelperMock,
731 'storeManager' => $this->storeManagerMock,
732 'checkoutSession' => $this->checkoutSessionMock,
733 'customerSession' => $this->customerSessionMock,
734 'accountManagement' => $this->accountManagementMock,
735 'quoteFactory' => $this->quoteFactoryMock
740 $orderMock = $this->createMock(\
Magento\Sales\Model\Order::class);
742 $this->quoteRepositoryMock->expects($this->once())
743 ->method(
'getActive')
745 ->willReturn($this->quoteMock);
747 $quotePayment = $this->createMock(\
Magento\Quote\Model\Quote\Payment::class);
748 $quotePayment->expects($this->once())
749 ->method(
'setQuote');
750 $quotePayment->expects($this->once())
751 ->method(
'importData');
752 $this->quoteMock->expects($this->atLeastOnce())
753 ->method(
'getPayment')
754 ->willReturn($quotePayment);
756 $this->quoteMock->expects($this->once())
757 ->method(
'getCheckoutMethod')
758 ->willReturn(\
Magento\Checkout\Model\Type\Onepage::METHOD_CUSTOMER);
759 $this->quoteMock->expects($this->never())
760 ->method(
'setCustomerIsGuest')
763 $service->expects($this->once())->method(
'submit')->willReturn($orderMock);
765 $this->quoteMock->expects($this->atLeastOnce())->method(
'getId')->willReturn(
$cartId);
767 $orderMock->expects($this->atLeastOnce())->method(
'getId')->willReturn($orderId);
768 $orderMock->expects($this->atLeastOnce())->method(
'getIncrementId')->willReturn($orderIncrementId);
769 $orderMock->expects($this->atLeastOnce())->method(
'getStatus')->willReturn(
$orderStatus);
771 $this->checkoutSessionMock->expects($this->once())->method(
'setLastQuoteId')->with(
$cartId);
772 $this->checkoutSessionMock->expects($this->once())->method(
'setLastSuccessQuoteId')->with(
$cartId);
773 $this->checkoutSessionMock->expects($this->once())->method(
'setLastOrderId')->with($orderId);
774 $this->checkoutSessionMock->expects($this->once())->method(
'setLastRealOrderId')->with($orderIncrementId);
775 $this->checkoutSessionMock->expects($this->once())->method(
'setLastOrderStatus')->with(
$orderStatus);
777 $paymentMethod = $this->createPartialMock(\
Magento\Quote\Model\Quote\Payment::class, [
'setChecks',
'getData']);
778 $paymentMethod->expects($this->once())->method(
'setChecks');
779 $paymentMethod->expects($this->once())->method(
'getData')->willReturn([
'additional_data' => []]);
781 $this->assertEquals($orderId,
$service->placeOrder(
$cartId, $paymentMethod));
805 $quote = $this->createPartialMock(
810 'getAllVisibleItems',
811 'getCustomerIsGuest',
814 'getShippingAddress',
824 $quote->expects($this->once())
825 ->method(
'setIsActive')
827 $quote->expects($this->any())
828 ->method(
'getAllVisibleItems')
829 ->willReturn($quoteItems);
830 $quote->expects($this->once())
831 ->method(
'getAllItems')
832 ->willReturn($quoteItems);
833 $quote->expects($this->once())
834 ->method(
'getCustomerIsGuest')
835 ->willReturn($isGuest);
836 $quote->expects($this->any())
837 ->method(
'isVirtual')
838 ->willReturn($isVirtual);
840 $quote->expects($this->any())
841 ->method(
'getShippingAddress')
844 $quote->expects($this->any())
845 ->method(
'getBillingAddress')
847 $quote->expects($this->once())
848 ->method(
'getPayment')
852 \
Magento\Customer\Model\Customer::class,
853 [
'getDefaultBilling',
'getId']
860 $quote->expects($this->atLeastOnce())
861 ->method(
'getCustomerEmail')
862 ->willReturn(
'customer@example.com');
863 $quote->expects($this->any())
864 ->method(
'getCustomer')
866 $quote->expects($this->once())
869 $this->customerRepositoryMock->expects($this->any())->method(
'getById')->willReturn(
$customer);
871 $customer->expects($this->any())->method(
'getDefaultBilling')->willReturn(1);
895 $order = $this->createPartialMock(
896 \
Magento\Sales\Model\Order::class,
898 'setShippingAddress',
899 'getAddressesCollection',
911 $this->orderFactory->expects($this->once())
914 $this->orderFactory->expects($this->never())
922 $this->orderFactory->expects($this->once())
923 ->method(
'setCustomerId')
926 $order->expects($this->any())->method(
'getAddressesCollection');
927 $order->expects($this->any())->method(
'getAddresses');
928 $order->expects($this->any())->method(
'getBillingAddress')->willReturn(
false);
929 $order->expects($this->any())->method(
'addAddresses')->withAnyParameters()->willReturnSelf();
932 $order->expects($this->once())->method(
'setPayment')->with(
$payment);
933 $order->expects($this->once())->method(
'setItems')->with(
$items);
934 $order->expects($this->once())->method(
'setQuoteId')->with(
$quoteId);
942 $cartMock = $this->createMock(\
Magento\
Quote\Model\Quote::class);
943 $this->quoteRepositoryMock->expects($this->once())
944 ->method(
'getActiveForCustomer')
946 ->willReturn($cartMock);
947 $this->assertEquals($cartMock, $this->model->getCartForCustomer(
$customerId));
959 $reflection = new \ReflectionClass(get_class($object));
960 $reflectionProperty = $reflection->getProperty($property);
961 $reflectionProperty->setAccessible(
true);
963 return $reflectionProperty->getValue($object);
975 $reflection = new \ReflectionClass(get_class($object));
976 $reflectionProperty = $reflection->getProperty($property);
977 $reflectionProperty->setAccessible(
true);
978 $reflectionProperty->setValue($object,
$value);
994 $baseOrder = $this->createMock(\
Magento\Sales\Api\Data\OrderInterface::class);
995 $convertedBilling = $this->createPartialMockForAbstractClass(OrderAddressInterface::class, [
'setData']);
996 $convertedShipping = $this->createPartialMockForAbstractClass(OrderAddressInterface::class, [
'setData']);
997 $convertedPayment = $this->createMock(\
Magento\Sales\Api\Data\OrderPaymentInterface::class);
998 $convertedQuoteItem = $this->createMock(\
Magento\Sales\Api\Data\OrderItemInterface::class);
1000 $addresses = [$convertedShipping, $convertedBilling];
1002 $convertedItems = [$convertedQuoteItem];
1015 $this->quoteValidator->expects($this->once())->method(
'validateBeforeSubmit')->with(
$quote);
1016 $this->quoteAddressToOrder->expects($this->once())
1019 ->willReturn($baseOrder);
1020 $this->quoteAddressToOrderAddress->expects($this->at(0))
1025 'address_type' =>
'shipping',
1026 'email' =>
'customer@example.com' 1029 ->willReturn($convertedShipping);
1030 $this->quoteAddressToOrderAddress->expects($this->at(1))
1035 'address_type' =>
'billing',
1036 'email' =>
'customer@example.com' 1039 ->willReturn($convertedBilling);
1040 $this->quoteItemToOrderItem->expects($this->once())->method(
'convert')
1042 ->willReturn($convertedQuoteItem);
1043 $this->quotePaymentToOrderPayment->expects($this->once())->method(
'convert')->with(
$payment)
1044 ->willReturn($convertedPayment);
1045 $shippingAddress->expects($this->once())->method(
'getShippingMethod')->willReturn(
'free');
1047 $convertedShipping->expects($this->once())->method(
'setData')->with(
'quote_address_id', 5);
1057 $customerAddressMock = $this->getMockBuilder(\
Magento\Customer\Api\Data\AddressInterface::class)
1058 ->getMockForAbstractClass();
1059 $shippingAddress->expects($this->once())->method(
'exportCustomerAddress')->willReturn($customerAddressMock);
1060 $this->addressRepositoryMock->expects($this->once())->method(
'save')->with($customerAddressMock);
1061 $quote->expects($this->any())->method(
'addCustomerAddress')->with($customerAddressMock);
1062 $billingAddress->expects($this->once())->method(
'getCustomerId')->willReturn(2);
1063 $billingAddress->expects($this->once())->method(
'getSaveInAddressBook')->willReturn(
false);
1064 $billingAddress->expects($this->once())->method(
'getId')->willReturn(4);
1065 $convertedBilling->expects($this->once())->method(
'setData')->with(
'quote_address_id', 4);
1066 $this->orderManagement->expects($this->once())
1070 $this->eventManager->expects($this->at(0))
1071 ->method(
'dispatch')
1072 ->with(
'sales_model_service_quote_submit_before', [
'order' =>
$order,
'quote' =>
$quote]);
1073 $this->eventManager->expects($this->at(1))
1074 ->method(
'dispatch')
1075 ->with(
'sales_model_service_quote_submit_success', [
'order' =>
$order,
'quote' =>
$quote]);
1076 $this->quoteRepositoryMock->expects($this->once())->method(
'save')->with(
$quote);
1077 $this->assertEquals(
$order, $this->model->submit(
$quote, $orderData));
1090 return $this->getMockForAbstractClass(
testAssignCustomerNoSuchCustomer()
testAssignCustomerToNonanonymousCart()
testAssignCustomerFromAnotherStore()
$quoteAddressToOrderAddress
testCreateEmptyCartAnonymous()
prepareOrderFactory(\Magento\Sales\Api\Data\OrderInterface $baseOrder, OrderAddressInterface $billingAddress, array $addresses, $payment, array $items, $quoteId, OrderAddressInterface $shippingAddress=null, $customerId=null)
getQuote( $isGuest, $isVirtual, \Magento\Quote\Model\Quote\Address $billingAddress, \Magento\Quote\Model\Quote\Payment $payment, $customerId, $id, array $quoteItems, \Magento\Quote\Model\Quote\Address $shippingAddress=null)
getPropertyValue($object, $property)
testCreateEmptyCartForCustomer()
$quotePaymentToOrderPayment
setPropertyValue(&$object, $property, $value)
testCreateEmptyCartForCustomerReturnExistsQuote()