2727use Magento \Tax \Api \TaxClassRepositoryInterface ;
2828use Magento \Tax \Model \ClassModel ;
2929use Magento \Tax \Model \Config as TaxConfig ;
30+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
31+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
3032use Magento \TestFramework \Helper \Bootstrap ;
3133use Magento \TestFramework \Quote \Model \GetQuoteByReservedOrderId ;
3234use PHPUnit \Framework \TestCase ;
@@ -48,6 +50,11 @@ class ShippingMethodManagementTest extends TestCase
4850 /** @var TaxClassRepositoryInterface $taxClassRepository */
4951 private $ taxClassRepository ;
5052
53+ /**
54+ * @var DataFixtureStorage
55+ */
56+ private $ fixtures ;
57+
5158 /**
5259 * @inheritdoc
5360 */
@@ -56,6 +63,7 @@ protected function setUp(): void
5663 $ this ->objectManager = Bootstrap::getObjectManager ();
5764 $ this ->groupRepository = $ this ->objectManager ->get (GroupRepositoryInterface::class);
5865 $ this ->taxClassRepository = $ this ->objectManager ->get (TaxClassRepositoryInterface::class);
66+ $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
5967 }
6068
6169 /**
@@ -126,33 +134,42 @@ public function testTableRateFreeShipping()
126134 }
127135
128136 /**
137+ * phpcs:disable Generic.Files.LineLength.TooLong
138+ *
129139 * @magentoConfigFixture default_store carriers/tablerate/active 1
130140 * @magentoConfigFixture default_store carriers/flatrate/active 0
131141 * @magentoConfigFixture current_store carriers/tablerate/condition_name package_value_with_discount
132142 * @magentoConfigFixture default_store carriers/tablerate/include_virtual_price 0
133- * @magentoDataFixture Magento/Sales/_files/quote_with_simple_and_virtual_product.php
143+ * @magentoDataFixture Magento\Catalog\Test\Fixture\Product with:{"sku":"simple", "type_id":"simple"} as:p1
144+ * @magentoDataFixture Magento\Catalog\Test\Fixture\Product with:{"sku":"virtual", "type_id":"virtual", "weight":0} as:p2
145+ * @magentoDataFixture Magento\Quote\Test\Fixture\GuestCart as:cart
146+ * @magentoDataFixture Magento\Quote\Test\Fixture\AddProductToCart with:{"cart_id":"$cart.id$", "product_id":"$p1.id$"}
147+ * @magentoDataFixture Magento\Quote\Test\Fixture\AddProductToCart with:{"cart_id":"$cart.id$", "product_id":"$p2.id$"}
148+ * @magentoDataFixture Magento\Quote\Test\Fixture\SetBillingAddress with:{"cart_id":"$cart.id$"}
149+ * @magentoDataFixture Magento\Quote\Test\Fixture\SetShippingAddress with:{"cart_id":"$cart.id$"}
134150 * @magentoDataFixture Magento/OfflineShipping/_files/tablerates_price.php
135151 * @return void
152+ * @throws NoSuchEntityException
136153 */
137154 public function testTableRateWithoutIncludingVirtualProduct ()
138155 {
139- $ quote = $ this ->getQuote ('quoteWithVirtualProduct ' );
140- $ cartId = $ quote ->getId ();
156+ $ cartId = (int )$ this ->fixtures ->get ('cart ' )->getId ();
141157
142158 if (!$ cartId ) {
143159 $ this ->fail ('quote fixture failed ' );
144160 }
145161
146- /** @var QuoteIdMask $quoteIdMask */
147- $ quoteIdMask = $ this ->objectManager
148- ->create (QuoteIdMaskFactory::class)
149- ->create ()
150- ->load ($ cartId , 'quote_id ' );
162+ /** @var QuoteRepository $quoteRepository */
163+ $ quoteRepository = $ this ->objectManager ->get (QuoteRepository::class);
164+ $ quote = $ quoteRepository ->get ($ cartId );
151165
152- /** @var GuestShippingMethodManagementInterface $shippingEstimation */
166+ /** @var QuoteIdToMaskedQuoteIdInterface $maskedQuoteId */
167+ $ maskedQuoteId = $ this ->objectManager ->get (QuoteIdToMaskedQuoteIdInterface::class)->execute ($ cartId );
168+
169+ /** @var GuestShippingMethodManagementInterface $shippingEstimation */
153170 $ shippingEstimation = $ this ->objectManager ->get (GuestShippingMethodManagementInterface::class);
154171 $ result = $ shippingEstimation ->estimateByExtendedAddress (
155- $ quoteIdMask -> getMaskedId () ,
172+ $ maskedQuoteId ,
156173 $ quote ->getShippingAddress ()
157174 );
158175
0 commit comments