Skip to content

Commit a1c8093

Browse files
committed
MSI-1650: Fix CE integration test
1 parent 56eae2a commit a1c8093

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidatorTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private function setMockStockStateResultToQuoteItemOptions($quoteItem, $resultMo
170170
* Tests quantity verifications for configurable product.
171171
*
172172
* @param int $quantity - quantity of configurable option.
173-
* @param string $errorMessage - expected error message.
173+
* @param string $errorMessageRegexp - expected error message regexp.
174174
* @return void
175175
* @throws CouldNotSaveException
176176
* @throws LocalizedException
@@ -179,7 +179,7 @@ private function setMockStockStateResultToQuoteItemOptions($quoteItem, $resultMo
179179
* @magentoDbIsolation enabled
180180
* @magentoAppIsolation enabled
181181
*/
182-
public function testConfigurableWithOptions(int $quantity, string $errorMessage): void
182+
public function testConfigurableWithOptions(int $quantity, string $errorMessageRegexp): void
183183
{
184184
/** @var ProductRepositoryInterface $productRepository */
185185
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
@@ -217,17 +217,16 @@ public function testConfigurableWithOptions(int $quantity, string $errorMessage)
217217
]
218218
);
219219

220-
if (!empty($errorMessage)) {
221-
$this->expectException(LocalizedException::class);
222-
$this->expectExceptionMessage($errorMessage);
223-
}
224-
225-
/** @var Quote $cart */
226-
$cart = $this->objectManager->create(CartInterface::class);
227-
$result = $cart->addProduct($product, $request);
220+
try {
221+
/** @var Quote $cart */
222+
$cart = $this->objectManager->create(CartInterface::class);
223+
$result = $cart->addProduct($product, $request);
228224

229-
if (empty($errorMessage)) {
230-
self::assertEquals('Configurable Product', $result->getName());
225+
if (empty($errorMessageRegexp)) {
226+
self::assertEquals('Configurable Product', $result->getName());
227+
}
228+
} catch (LocalizedException $e) {
229+
self::assertEquals(1, preg_match($errorMessageRegexp, $e->getMessage()));
231230
}
232231
}
233232

@@ -239,18 +238,20 @@ public function testConfigurableWithOptions(int $quantity, string $errorMessage)
239238
*/
240239
public function quantityDataProvider(): array
241240
{
241+
$qtyRegexp = '/You can buy (this product|Configurable OptionOption 1) only in quantities of 500 at a time/';
242+
242243
return [
243244
[
244245
'quantity' => 1,
245-
'error' => 'The fewest you may purchase is 500.'
246+
'error_regexp' => '/The fewest you may purchase is 500\./'
246247
],
247248
[
248249
'quantity' => 501,
249-
'error' => 'You can buy Configurable OptionOption 1 only in quantities of 500 at a time'
250+
'error_regexp' => $qtyRegexp
250251
],
251252
[
252253
'quantity' => 1000,
253-
'error' => ''
254+
'error_regexp' => ''
254255
],
255256

256257
];

0 commit comments

Comments
 (0)