![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/testsuite/Magento/Quote/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Quote\Model; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\ObjectManagerInterface; use Magento\Quote\Api\CartRepositoryInterface; use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper; use PHPUnit\Framework\TestCase; /** * @magentoDbIsolation disabled * @magentoAppArea adminhtml */ class CustomerManagementTest extends TestCase { /** * @var ObjectManagerInterface */ private $objectManager; /** * @var CustomerManagement */ private $customerManagemet; /** * @var CustomerInterface */ private $customer; protected function setUp(): void { $this->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('[email protected]'); $customerRepository->delete($customer); } /** * @magentoDataFixture Magento/Sales/_files/quote.php */ public function testCustomerAddressIdQuote(): void { $reservedOrderId = 'test01'; $this->customer->setEmail('[email protected]') ->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); } }