/** * 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)); }
/** * Get Order Model * * @param OrderData $dataObject * @return Order * @throws \Exception */ public function getModel(OrderData $dataObject) { $this->orderBuilder->setCustomer($this->getCustomer($dataObject))->setQuoteId($dataObject->getQuoteId())->setAppliedRuleIds($dataObject->getAppliedRuleIds())->setIsVirtual($dataObject->getIsVirtual())->setRemoteIp($dataObject->getRemoteIp())->setBaseSubtotal($dataObject->getBaseSubtotal())->setSubtotal($dataObject->getSubtotal())->setBaseGrandTotal($dataObject->getBaseGrandTotal())->setGrandTotal($dataObject->getGrandTotal())->setBaseCurrencyCode($dataObject->getBaseCurrencyCode())->setGlobalCurrencyCode($dataObject->getGlobalCurrencyCode())->setStoreCurrencyCode($dataObject->getStoreCurrencyCode())->setStoreId($dataObject->getStoreId())->setStoreToBaseRate($dataObject->getStoreToBaseRate())->setBaseToGlobalRate($dataObject->getBaseToGlobalRate())->setCouponCode($dataObject->getCouponCode())->setBillingAddress($this->addressConverter->getModel($dataObject->getBillingAddress()))->setShippingAddress($this->addressConverter->getModel($dataObject->getShippingAddress()))->setPayments($this->getPayments($dataObject))->setItems($this->getItems($dataObject)); return $this->orderBuilder->create(); }
/** * Invoke order address update service * * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress * @return bool */ public function invoke(OrderAddress $orderAddress) { $orderAddressModel = $this->addressConverter->getModel($orderAddress); $orderAddressModel->save(); return true; }