Skip to content

Commit fbdece0

Browse files
committed
MCP584: Fix failed Integration tests
1 parent d5652b9 commit fbdece0

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

app/code/Magento/Quote/Model/Config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function __construct(ScopeConfigInterface $config)
3535
*/
3636
public function isEnabled(): bool
3737
{
38-
#return (bool)$this->config->getValue(self::XML_PATH_INVENTORY_CHECK_ENABLED);
39-
return false;
38+
return (bool)$this->config->getValue(self::XML_PATH_INVENTORY_CHECK_ENABLED);
4039
}
4140
}

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public function testSubmitWithPurchaseOrderWithException(): void
181181
/**
182182
* Tries to create order with product that has child items and one of them was deleted.
183183
*
184+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
184185
* @magentoAppArea adminhtml
185186
* @magentoAppIsolation enabled
186187
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
@@ -195,9 +196,25 @@ public function testSubmitWithDeletedItem(): void
195196
$this->cartManagement->placeOrder($quote->getId());
196197
}
197198

199+
200+
/**
201+
* Tries to create order with product that has child items and one of them
202+
* was deleted when item data check is disabled on quote load.
203+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
204+
* @magentoAppArea adminhtml
205+
* @magentoAppIsolation enabled
206+
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
207+
*/
208+
public function testSubmitWithDeletedItemWithDisabledInventoryCheck(): void
209+
{
210+
$this->productRepository->deleteById('simple-2');
211+
$quote = $this->getQuoteByReservedOrderId->execute('test01');
212+
$this->cartManagement->placeOrder($quote->getId());
213+
}
214+
198215
/**
199216
* Tries to create order with item of stock during checkout.
200-
*
217+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
201218
* @magentoDataFixture Magento/Sales/_files/quote.php
202219
* @magentoDbIsolation enabled
203220
*/
@@ -209,6 +226,21 @@ public function testSubmitWithItemOutOfStock(): void
209226
$this->cartManagement->placeOrder($quote->getId());
210227
}
211228

229+
/**
230+
* Tries to create order with item of stock during checkout
231+
* when item data check is disabled on quote load.
232+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
233+
* @magentoDataFixture Magento/Sales/_files/quote.php
234+
* @magentoDbIsolation enabled
235+
*/
236+
public function testSubmitWithItemOutOfStockWithDisabledInventoryCheck(): void
237+
{
238+
$this->makeProductOutOfStock('simple');
239+
$quote = $this->getQuoteByReservedOrderId->execute('test01');
240+
$this->expectExceptionObject(new LocalizedException(__('The shipping method is missing. Select the shipping method and try again.')));
241+
$this->cartManagement->placeOrder($quote->getId());
242+
}
243+
212244
/**
213245
* Tries to create an order using quote with empty customer email.
214246
*

dev/tests/integration/testsuite/Magento/Sales/Model/Service/PaymentFailuresServiceTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ protected function setUp(): void
6363
}
6464

6565
/**
66+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
6667
* @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer.php
6768
* @magentoConfigFixture current_store payment/payflowpro/title Some Title Of The Method
6869
* @magentoConfigFixture current_store carriers/freeshipping/title Some Shipping Method
@@ -107,4 +108,51 @@ public function testHandlerWithCustomer(): void
107108

108109
$this->assertEquals($expectedVars, $templateVars);
109110
}
111+
112+
/**
113+
* @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
114+
* @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer.php
115+
* @magentoConfigFixture current_store payment/payflowpro/title Some Title Of The Method
116+
* @magentoConfigFixture current_store carriers/freeshipping/title Some Shipping Method
117+
* @magentoDbIsolation enabled
118+
* @magentoAppIsolation enabled
119+
* @return void
120+
*/
121+
public function testHandlerWithCustomerWithInventoryCheckDisabled(): void
122+
{
123+
$errorMessage = __('Transaction declined.');
124+
$checkoutType = 'custom_checkout';
125+
126+
$this->quote->load('test01', 'reserved_order_id');
127+
$this->cartRepositoryMock->method('get')
128+
->with($this->quote->getId())
129+
->willReturn($this->quote);
130+
131+
$dateAndTime = 'Nov 22, 2019, 1:00:00 AM';
132+
$this->localeDateMock->expects($this->atLeastOnce())->method('formatDateTime')->willReturn($dateAndTime);
133+
$this->paymentFailures->handle((int)$this->quote->getId(), $errorMessage->render());
134+
135+
$paymentReflection = new \ReflectionClass($this->paymentFailures);
136+
$templateVarsMethod = $paymentReflection->getMethod('getTemplateVars');
137+
$templateVarsMethod->setAccessible(true);
138+
139+
$templateVars = $templateVarsMethod->invoke($this->paymentFailures, $this->quote, $errorMessage, $checkoutType);
140+
$expectedVars = [
141+
'reason' => $errorMessage->render(),
142+
'checkoutType' => $checkoutType,
143+
'dateAndTime' => $dateAndTime,
144+
'customer' => 'John Smith',
145+
'customerEmail' => 'aaa@aaa.com',
146+
'paymentMethod' => 'Some Title Of The Method',
147+
'shippingMethod' => 'Some Shipping Method',
148+
'items' => 'Simple Product x 2.0000 USD 10<br />Custom Design Simple Product x 1.0000 USD 10',
149+
'total' => 'USD 30.0000',
150+
'billingAddress' => $this->quote->getBillingAddress(),
151+
'shippingAddress' => $this->quote->getShippingAddress(),
152+
'billingAddressHtml' => $this->quote->getBillingAddress()->format('html'),
153+
'shippingAddressHtml' => $this->quote->getShippingAddress()->format('html'),
154+
];
155+
156+
$this->assertEquals($expectedVars, $templateVars);
157+
}
110158
}

0 commit comments

Comments
 (0)