/** * test Order Address Update service */ public function testInvoke() { $dtoMock = $this->getMock('\\Magento\\Sales\\Service\\V1\\Data\\OrderAddress', [], [], '', false); $orderAddressModel = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['save', '__wakeup'], [], '', false); $this->addressConverterMock->expects($this->once())->method('getModel')->with($this->equalTo($dtoMock))->will($this->returnValue($orderAddressModel)); $orderAddressModel->expects($this->once())->method('save')->will($this->returnSelf()); $this->orderAddressUpdate->invoke($dtoMock); }
public function testGetModel() { $billingAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['__wakeup'], [], '', false); $shippingAddressMock = clone $billingAddressMock; $this->addressConverterMock->expects($this->at(0))->method('getModel')->with($this->orderData['billingAddress'])->will($this->returnValue($billingAddressMock)); $this->addressConverterMock->expects($this->at(1))->method('getModel')->with($this->orderData['shippingAddress'])->will($this->returnValue($shippingAddressMock)); $this->orderBuilderMock->expects($this->once())->method('setCustomer')->with($this->getCustomer())->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setQuoteId')->with($this->orderData['quoteId'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setAppliedRuleIds')->with($this->orderData['appliedRuleIds'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setIsVirtual')->with($this->orderData['isVirtual'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setRemoteIp')->with($this->orderData['remoteIp'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setBaseSubtotal')->with($this->orderData['baseSubtotal'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setSubtotal')->with($this->orderData['subtotal'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setBaseGrandTotal')->with($this->orderData['baseGrandTotal'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setGrandTotal')->with($this->orderData['grandTotal'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setBaseCurrencyCode')->with($this->orderData['baseCurrencyCode'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setGlobalCurrencyCode')->with($this->orderData['globalCurrencyCode'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setStoreCurrencyCode')->with($this->orderData['storeCurrencyCode'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setStoreId')->with($this->orderData['storeId'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setStoreToBaseRate')->with($this->orderData['storeToBaseRate'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setBaseToGlobalRate')->with($this->orderData['baseToGlobalRate'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setCouponCode')->with($this->orderData['couponCode'])->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock)->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setShippingAddress')->with($shippingAddressMock)->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setPayments')->with($this->getPayments())->will($this->returnSelf()); $this->orderBuilderMock->expects($this->once())->method('setItems')->with($this->getItems())->will($this->returnSelf()); $orderMock = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false); $this->orderBuilderMock->expects($this->once())->method('create')->will($this->returnValue($orderMock)); $this->assertEquals($orderMock, $this->orderConverter->getModel($this->orderDataMock)); }