objectManager = BootstrapHelper::getObjectManager(); $this->customerManagemet = $this->objectManager->create(CustomerManagement::class); $this->customer = $this->objectManager->create(CustomerInterface::class); } protected function tearDown(): void { /** @var CustomerRepositoryInterface $customerRepository */ $customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class); $customer = $customerRepository->get('john1.doe001@test.com'); $customerRepository->delete($customer); } /** * @magentoDataFixture Magento/Sales/_files/quote.php */ public function testCustomerAddressIdQuote(): void { $reservedOrderId = 'test01'; $this->customer->setEmail('john1.doe001@test.com') ->setFirstname('doe') ->setLastname('john'); $quote = $this->getQuote($reservedOrderId)->setCustomer($this->customer); $this->customerManagemet->populateCustomerInfo($quote); self::assertNotNull($quote->getBillingAddress()->getCustomerAddressId()); self::assertNotNull($quote->getShippingAddress()->getCustomerAddressId()); } /** * Gets quote by reserved order ID. * * @param string $reservedOrderId * @return Quote */ private function getQuote(string $reservedOrderId): Quote { /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId) ->create(); /** @var CartRepositoryInterface $quoteRepository */ $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); $items = $quoteRepository->getList($searchCriteria) ->getItems(); return array_pop($items); } }