|
14 | 14 | use Magento\Customer\Api\Data\CustomerInterfaceFactory;
|
15 | 15 | use Magento\Customer\Model\Data\Customer;
|
16 | 16 | use Magento\Framework\Exception\LocalizedException;
|
| 17 | +use Magento\Quote\Api\Data\AddressInterface; |
17 | 18 | use Magento\TestFramework\Helper\Bootstrap;
|
18 | 19 | use Magento\TestFramework\ObjectManager;
|
19 | 20 | use Magento\Framework\Api\SearchCriteriaBuilder;
|
@@ -72,6 +73,46 @@ public function testCollectTotalsWithVirtual(): void
|
72 | 73 | $this->assertEquals(20, $quote->getBaseGrandTotal());
|
73 | 74 | }
|
74 | 75 |
|
| 76 | + /** |
| 77 | + * @magentoDataFixture Magento/Catalog/_files/product_virtual.php |
| 78 | + * @magentoDataFixture Magento/Quote/_files/empty_quote.php |
| 79 | + * @return void |
| 80 | + */ |
| 81 | + public function testGetAddressWithVirtualProduct() |
| 82 | + { |
| 83 | + /** @var Quote $quote */ |
| 84 | + $quote = $this->objectManager->create(Quote::class); |
| 85 | + $quote->load('reserved_order_id_1', 'reserved_order_id'); |
| 86 | + $billingAddress = $this->objectManager->create(AddressInterface::class); |
| 87 | + $billingAddress->setFirstname('Joe') |
| 88 | + ->setLastname('Doe') |
| 89 | + ->setCountryId('US') |
| 90 | + ->setRegion('TX') |
| 91 | + ->setCity('Austin') |
| 92 | + ->setStreet('1000 West Parmer Line') |
| 93 | + ->setPostcode('11501') |
| 94 | + ->setTelephone('123456789'); |
| 95 | + $quote->setBillingAddress($billingAddress); |
| 96 | + $shippingAddress = $this->objectManager->create(AddressInterface::class); |
| 97 | + $shippingAddress->setFirstname('Joe') |
| 98 | + ->setLastname('Doe') |
| 99 | + ->setCountryId('US') |
| 100 | + ->setRegion('NJ') |
| 101 | + ->setCity('Newark') |
| 102 | + ->setStreet('2775 Granville Lane') |
| 103 | + ->setPostcode('07102') |
| 104 | + ->setTelephone('9734685221'); |
| 105 | + $quote->setShippingAddress($shippingAddress); |
| 106 | + $productRepository = $this->objectManager->create( |
| 107 | + ProductRepositoryInterface::class |
| 108 | + ); |
| 109 | + $product = $productRepository->get('virtual-product', false, null, true); |
| 110 | + $quote->addProduct($product); |
| 111 | + $quote->save(); |
| 112 | + $expectedAddress = $quote->getBillingAddress(); |
| 113 | + $this->assertEquals($expectedAddress, $quote->getAllItems()[0]->getAddress()); |
| 114 | + } |
| 115 | + |
75 | 116 | /**
|
76 | 117 | * @return void
|
77 | 118 | */
|
|
0 commit comments