27
27
use Magento \Tax \Api \TaxClassRepositoryInterface ;
28
28
use Magento \Tax \Model \ClassModel ;
29
29
use Magento \Tax \Model \Config as TaxConfig ;
30
+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
31
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
30
32
use Magento \TestFramework \Helper \Bootstrap ;
31
33
use Magento \TestFramework \Quote \Model \GetQuoteByReservedOrderId ;
32
34
use PHPUnit \Framework \TestCase ;
@@ -48,6 +50,11 @@ class ShippingMethodManagementTest extends TestCase
48
50
/** @var TaxClassRepositoryInterface $taxClassRepository */
49
51
private $ taxClassRepository ;
50
52
53
+ /**
54
+ * @var DataFixtureStorage
55
+ */
56
+ private $ fixtures ;
57
+
51
58
/**
52
59
* @inheritdoc
53
60
*/
@@ -56,6 +63,7 @@ protected function setUp(): void
56
63
$ this ->objectManager = Bootstrap::getObjectManager ();
57
64
$ this ->groupRepository = $ this ->objectManager ->get (GroupRepositoryInterface::class);
58
65
$ this ->taxClassRepository = $ this ->objectManager ->get (TaxClassRepositoryInterface::class);
66
+ $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
59
67
}
60
68
61
69
/**
@@ -126,33 +134,42 @@ public function testTableRateFreeShipping()
126
134
}
127
135
128
136
/**
137
+ * phpcs:disable Generic.Files.LineLength.TooLong
138
+ *
129
139
* @magentoConfigFixture default_store carriers/tablerate/active 1
130
140
* @magentoConfigFixture default_store carriers/flatrate/active 0
131
141
* @magentoConfigFixture current_store carriers/tablerate/condition_name package_value_with_discount
132
142
* @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$"}
134
150
* @magentoDataFixture Magento/OfflineShipping/_files/tablerates_price.php
135
151
* @return void
152
+ * @throws NoSuchEntityException
136
153
*/
137
154
public function testTableRateWithoutIncludingVirtualProduct ()
138
155
{
139
- $ quote = $ this ->getQuote ('quoteWithVirtualProduct ' );
140
- $ cartId = $ quote ->getId ();
156
+ $ cartId = (int )$ this ->fixtures ->get ('cart ' )->getId ();
141
157
142
158
if (!$ cartId ) {
143
159
$ this ->fail ('quote fixture failed ' );
144
160
}
145
161
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 );
151
165
152
- /** @var GuestShippingMethodManagementInterface $shippingEstimation */
166
+ /** @var QuoteIdToMaskedQuoteIdInterface $maskedQuoteId */
167
+ $ maskedQuoteId = $ this ->objectManager ->get (QuoteIdToMaskedQuoteIdInterface::class)->execute ($ cartId );
168
+
169
+ /** @var GuestShippingMethodManagementInterface $shippingEstimation */
153
170
$ shippingEstimation = $ this ->objectManager ->get (GuestShippingMethodManagementInterface::class);
154
171
$ result = $ shippingEstimation ->estimateByExtendedAddress (
155
- $ quoteIdMask -> getMaskedId () ,
172
+ $ maskedQuoteId ,
156
173
$ quote ->getShippingAddress ()
157
174
);
158
175
0 commit comments