diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off_rollback.php index c6e145842f291..964a6248c1c10 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off_rollback.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_40_percent_off_rollback.php @@ -3,13 +3,27 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + declare(strict_types=1); -/** @var Magento\Framework\Registry $registry */ -$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Magento\SalesRule\Api\RuleRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$bootstrap = Bootstrap::getObjectManager(); + +/** @var Registry $registry */ +$registry = $bootstrap->get(Registry::class); + +/** @var RuleRepositoryInterface $ruleRepository */ +$ruleRepository = $bootstrap->get(RuleRepositoryInterface::class); -/** @var Magento\SalesRule\Model\Rule $rule */ -$rule = $registry->registry('cart_rule_40_percent_off'); -if ($rule) { - $rule->delete(); +$ruleId = $registry->registry('Magento/SalesRule/_files/cart_rule_40_percent_off'); +if ($ruleId) { + try { + $ruleRepository->deleteById($ruleId); + $registry->unregister('Magento/SalesRule/_files/cart_rule_40_percent_off'); + } catch (NoSuchEntityException $e) { + } } diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off_rollback.php index d694e9972ec73..65e148f2cdb21 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off_rollback.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_50_percent_off_rollback.php @@ -3,13 +3,27 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + declare(strict_types=1); -/** @var Magento\Framework\Registry $registry */ -$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Magento\SalesRule\Api\RuleRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$bootstrap = Bootstrap::getObjectManager(); + +/** @var Registry $registry */ +$registry = $bootstrap->get(Registry::class); + +/** @var RuleRepositoryInterface $ruleRepository */ +$ruleRepository = $bootstrap->get(RuleRepositoryInterface::class); -/** @var Magento\SalesRule\Model\Rule $rule */ -$rule = $registry->registry('cart_rule_50_percent_off'); -if ($rule) { - $rule->delete(); +$ruleId = $registry->registry('Magento/SalesRule/_files/cart_rule_50_percent_off'); +if ($ruleId) { + try { + $ruleRepository->deleteById($ruleId); + $registry->unregister('Magento/SalesRule/_files/cart_rule_50_percent_off'); + } catch (NoSuchEntityException $e) { + } }