public function testSavePaymentInformation()
 {
     $cartId = 100;
     $email = '*****@*****.**';
     $paymentMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\PaymentInterface');
     $billingAddressMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\AddressInterface');
     $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();
     $this->billingAddressManagementMock->expects($this->once())->method('assign')->with($cartId, $billingAddressMock);
     $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock);
     $this->assertTrue($this->model->savePaymentInformation($cartId, $email, $paymentMock, $billingAddressMock));
 }
 public function testSavePaymentInformationWithoutBillingAddress()
 {
     $cartId = 100;
     $email = '*****@*****.**';
     $paymentMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\PaymentInterface');
     $billingAddressMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\AddressInterface');
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();
     $this->billingAddressManagementMock->expects($this->never())->method('assign');
     $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock);
     $quoteIdMaskMock = $this->getMock('Magento\\Quote\\Model\\QuoteIdMask', ['getQuoteId', 'load'], [], '', false);
     $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($cartId);
     $this->cartRepositoryMock->expects($this->once())->method('getActive')->with($cartId)->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
     $billingAddressMock->expects($this->once())->method('setEmail')->with($email);
     $this->assertTrue($this->model->savePaymentInformation($cartId, $email, $paymentMock));
 }