Пример #1
0
 /**
  * @param $conditions
  * @param $exportShippingCustomerAddressCalls
  * @param $exportBillingCustomerAddressCalls
  * @dataProvider prepareRegisteredCustomerQuoteDataProvider
  */
 public function testPrepareRegisteredCustomerQuote($conditions, $exportBillingCustomerAddressCalls, $exportShippingCustomerAddressCalls)
 {
     $customerDataMock = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->setMethods(['getDefaultShipping', 'getDefaultBilling'])->disableOriginalConstructor()->getMock();
     $customerDataMock->expects($this->any())->method('getDefaultBilling')->willReturn($conditions['isDefaultBilling']);
     $customerDataMock->expects($this->any())->method('getDefaultShipping')->willReturn($conditions['isDefaultShipping']);
     $this->customerRepositoryMock->expects($this->once())->method('getById')->willReturn($customerDataMock);
     $customerAddressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $shippingAddressMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Address')->setMethods(['getTelephone', 'getSameAsBilling', 'getCustomerId', 'getSaveInAddressBook', 'exportCustomerAddress'])->disableOriginalConstructor()->getMock();
     $shippingAddressMock->expects($this->any())->method('getTelephone')->willReturn($conditions['isTelephone']);
     $shippingAddressMock->expects($this->any())->method('getSameAsBilling')->willReturn($conditions['isShippingSameAsBilling']);
     $shippingAddressMock->expects($this->any())->method('getCustomerId')->willReturn(true);
     $shippingAddressMock->expects($this->any())->method('getSaveInAddressBook')->willReturn($conditions['isShippingSaveInAddressBook']);
     $shippingAddressMock->expects($this->exactly($exportShippingCustomerAddressCalls))->method('exportCustomerAddress')->willReturn($customerAddressMock);
     $billingAddressMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Address')->setMethods(['getTelephone', 'getCustomerId', 'getSaveInAddressBook', 'exportCustomerAddress'])->disableOriginalConstructor()->getMock();
     $billingAddressMock->expects($this->any())->method('getTelephone')->willReturn($conditions['isTelephone']);
     $billingAddressMock->expects($this->any())->method('getCustomerId')->willReturn(true);
     $billingAddressMock->expects($this->any())->method('getSaveInAddressBook')->willReturn($conditions['isBillingSaveInAddressBook']);
     $billingAddressMock->expects($this->exactly($exportBillingCustomerAddressCalls))->method('exportCustomerAddress')->willReturn($customerAddressMock);
     $this->quoteMock->expects($this->any())->method('isVirtual')->willReturn(false);
     $this->quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddressMock);
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingAddressMock);
     $this->assertInstanceOf('Magento\\Quote\\Model\\Quote', $this->quote->prepareRegisteredCustomerQuote($this->quoteMock, 1));
 }
Пример #2
0
 /**
  * Prepare quote for customer order submit
  *
  * @return void
  */
 protected function _prepareCustomerQuote()
 {
     $this->paypalQuote->prepareRegisteredCustomerQuote($this->_quote, $this->_customerSession->getCustomerId());
 }