quoteIdMaskFactoryMock = $this->createPartialMock( \Magento\Quote\Model\QuoteIdMaskFactory::class, ['create'] ); $this->shippingInformationManagementMock = $this->createMock( \Magento\Checkout\Api\ShippingInformationManagementInterface::class ); $this->model = $objectManager->getObject( \Magento\Checkout\Model\GuestShippingInformationManagement::class, [ 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, 'shippingInformationManagement' => $this->shippingInformationManagementMock ] ); } public function testSaveAddressInformation() { $cartId = 'masked_id'; $quoteId = 100; $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); $quoteIdMaskMock = $this->createPartialMock(\Magento\Quote\Model\QuoteIdMask::class, ['load', 'getQuoteId']); $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock); $quoteIdMaskMock->expects($this->once())->method('load')->with($cartId, 'masked_id')->willReturnSelf(); $quoteIdMaskMock->expects($this->once())->method('getQuoteId')->willReturn($quoteId); $paymentInformationMock = $this->createMock(\Magento\Checkout\Api\Data\PaymentDetailsInterface::class); $this->shippingInformationManagementMock->expects($this->once()) ->method('saveAddressInformation') ->with($quoteId, $addressInformationMock) ->willReturn($paymentInformationMock); $this->model->saveAddressInformation($cartId, $addressInformationMock); } }