public function testGetShippingAddress() { /** @var AddressAdapterInterface $addressAdapterMock */ $addressAdapterMock = $this->getMockBuilder('Magento\\Payment\\Gateway\\Data\\AddressAdapterInterface')->getMockForAbstractClass(); /** @var \Magento\Sales\Api\Data\OrderAddressInterface $orderAddressMock */ $orderAddressMock = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderAddressInterface')->getMockForAbstractClass(); $this->addressAdapterFactoryMock->expects($this->once())->method('create')->with(['address' => $orderAddressMock])->willReturn($addressAdapterMock); $this->orderMock->expects($this->once())->method('getShippingAddress')->willReturn($orderAddressMock); $this->assertSame($addressAdapterMock, $this->model->getShippingAddress()); }
/** * Create mock object for order adapter */ private function initOrderMock() { $this->billingAddress = $this->getMockBuilder(AddressAdapter::class)->disableOriginalConstructor()->setMethods(['getCountryId'])->getMock(); $this->order = $this->getMockBuilder(OrderAdapter::class)->disableOriginalConstructor()->setMethods(['getBillingAddress'])->getMock(); $this->order->expects(static::any())->method('getBillingAddress')->willReturn($this->billingAddress); }