|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; |
| 9 | +use Magento\Customer\Api\AddressRepositoryInterface; |
| 10 | +use Magento\Framework\Exception\NoSuchEntityException; |
| 11 | +use Magento\Framework\Registry; |
| 12 | +use Magento\TestFramework\Helper\Bootstrap; |
| 13 | + |
| 14 | +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php'); |
| 15 | +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php'); |
| 16 | + |
| 17 | +$objectManager = Bootstrap::getObjectManager(); |
| 18 | +/** @var Registry $registry */ |
| 19 | +$registry = $objectManager->get(Registry::class); |
| 20 | + |
| 21 | +$registry->unregister('isSecureArea'); |
| 22 | +$registry->register('isSecureArea', true); |
| 23 | + |
| 24 | +/** @var AddressRepositoryInterface $addressRepository */ |
| 25 | +$addressRepository = $objectManager->get(AddressRepositoryInterface::class); |
| 26 | + |
| 27 | +foreach ([1, 2] as $addressId) { |
| 28 | + try { |
| 29 | + $addressRepository->deleteById($addressId); |
| 30 | + } catch (NoSuchEntityException $e) { |
| 31 | + /** |
| 32 | + * Tests which are wrapped with MySQL transaction clear all data by transaction rollback. |
| 33 | + */ |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +$registry->unregister('isSecureArea'); |
| 38 | +$registry->register('isSecureArea', false); |
| 39 | + |
| 40 | +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_address_attribute_update_rollback.php'); |
0 commit comments