/** * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage Please check shipping address information. */ public function testSetShippingItemsInformationForAddressLeak() { $info = [[1 => ['qty' => 2, 'address' => 43]]]; $customerAddressId = 42; $customerAddressMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Address', [], [], '', false); $customerAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn($customerAddressId); $customerAddresses = [$customerAddressMock]; $quoteItemMock = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Item', [], [], '', false); $this->quoteMock->expects($this->once())->method('getItemById')->willReturn($quoteItemMock); $this->quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([]); $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock); $this->helperMock->expects($this->once())->method('getMaximumQty')->willReturn(500); $this->customerMock->expects($this->once())->method('getAddresses')->willReturn($customerAddresses); $this->assertEquals($this->model, $this->model->setShippingItemsInformation($info)); }