1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace TddWizard\Fixtures\Catalog; |
5
|
|
|
|
6
|
|
|
use Magento\Catalog\Model\Product; |
7
|
|
|
use Magento\Eav\Api\AttributeOptionManagementInterface; |
8
|
|
|
use Magento\Framework\Exception\InputException; |
9
|
|
|
use Magento\Framework\Exception\NoSuchEntityException; |
10
|
|
|
use Magento\Framework\Exception\StateException; |
11
|
|
|
use Magento\Framework\Registry; |
12
|
|
|
use Magento\TestFramework\Helper\Bootstrap; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Roll back one or more options. |
16
|
|
|
* |
17
|
|
|
* @internal Use OptionFixture::rollback() instead. |
18
|
|
|
*/ |
19
|
|
|
class OptionFixtureRollback |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var Registry |
24
|
|
|
*/ |
25
|
|
|
private $registry; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var AttributeOptionManagementInterface |
29
|
|
|
*/ |
30
|
|
|
private $optionManagement; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* OptionFixtureRollback constructor. |
34
|
|
|
* |
35
|
|
|
* @param Registry $registry |
36
|
|
|
* @param AttributeOptionManagementInterface $optionManagement |
37
|
|
|
*/ |
38
|
6 |
|
public function __construct(Registry $registry, AttributeOptionManagementInterface $optionManagement) |
39
|
|
|
{ |
40
|
6 |
|
$this->registry = $registry; |
41
|
6 |
|
$this->optionManagement = $optionManagement; |
42
|
6 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Create the object. |
46
|
|
|
* |
47
|
|
|
* @return OptionFixtureRollback |
48
|
|
|
*/ |
49
|
6 |
|
public static function create(): OptionFixtureRollback |
50
|
|
|
{ |
51
|
6 |
|
$objectManager = Bootstrap::getObjectManager(); |
52
|
6 |
|
return new self( |
53
|
6 |
|
$objectManager->get(Registry::class), |
54
|
6 |
|
$objectManager->get(AttributeOptionManagementInterface::class) |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Remove the given option(s). |
60
|
|
|
* |
61
|
|
|
* @param OptionFixture ...$optionFixtures |
62
|
|
|
* @throws InputException |
63
|
|
|
* @throws NoSuchEntityException |
64
|
|
|
* @throws StateException |
65
|
|
|
*/ |
66
|
6 |
|
public function execute(OptionFixture ...$optionFixtures): void |
67
|
|
|
{ |
68
|
6 |
|
$this->registry->unregister('isSecureArea'); |
|
|
|
|
69
|
6 |
|
$this->registry->register('isSecureArea', true); |
|
|
|
|
70
|
|
|
|
71
|
6 |
|
foreach ($optionFixtures as $optionFixture) { |
72
|
6 |
|
$this->optionManagement->delete( |
73
|
6 |
|
Product::ENTITY, |
|
|
|
|
74
|
6 |
|
$optionFixture->getAttributeCode(), |
75
|
6 |
|
$optionFixture->getOption()->getId() |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
6 |
|
$this->registry->unregister('isSecureArea'); |
|
|
|
|
80
|
6 |
|
} |
81
|
|
|
} |
82
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths