customerAddressDataFormatter = $this->createMock(CustomerAddressDataFormatter::class); $this->shareConfig = $this->createMock(Share::class); $this->allowedCountryReader = $this->createMock(AllowedCountries::class); $this->provider = new CustomerAddressDataProvider( $this->customerAddressDataFormatter, $this->shareConfig, $this->allowedCountryReader ); } /** * @return void * @throws \Magento\Framework\Exception\LocalizedException */ public function testGetAddressDataByCustomer(): void { $addressLimit = 1; $this->allowedCountryReader->expects($this->once())->method('getAllowedCountries')->willReturn(['1']); $this->customerAddressDataFormatter->expects($this->once()) ->method('prepareAddress') ->willreturn([1]); $this->shareConfig->expects($this->any())->method('isGlobalScope')->willReturn(false); $viableAddress = $this->getMockForAbstractClass(AddressInterface::class); $viableAddress->expects($this->once())->method('getId')->willReturn(1); $faultyAddress = $this->getMockForAbstractClass(AddressInterface::class); $customer = $this->getMockForAbstractClass(CustomerInterface::class); $customer->expects($this->once()) ->method('getAddresses') ->willReturn([$viableAddress, $faultyAddress]); $expectedResult = [ '1' => [1] ]; $this->assertSame($expectedResult, $this->provider->getAddressDataByCustomer($customer, $addressLimit)); } }