|
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 $attributeOptionManagement; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* OptionFixtureRollback constructor. |
|
34
|
|
|
* |
|
35
|
|
|
* @param Registry $registry |
|
36
|
|
|
* @param AttributeOptionManagementInterface $attributeOptionManagement |
|
37
|
|
|
*/ |
|
38
|
4 |
|
public function __construct(Registry $registry, AttributeOptionManagementInterface $attributeOptionManagement) |
|
39
|
|
|
{ |
|
40
|
4 |
|
$this->registry = $registry; |
|
41
|
4 |
|
$this->attributeOptionManagement = $attributeOptionManagement; |
|
42
|
4 |
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Create the object. |
|
46
|
|
|
* |
|
47
|
|
|
* @return OptionFixtureRollback |
|
48
|
|
|
*/ |
|
49
|
4 |
|
public static function create(): OptionFixtureRollback |
|
50
|
|
|
{ |
|
51
|
4 |
|
$objectManager = Bootstrap::getObjectManager(); |
|
52
|
4 |
|
return new self( |
|
53
|
4 |
|
$objectManager->get(Registry::class), |
|
54
|
4 |
|
$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
|
4 |
|
public function execute(OptionFixture ...$optionFixtures): void |
|
67
|
|
|
{ |
|
68
|
4 |
|
$this->registry->unregister('isSecureArea'); |
|
|
|
|
|
|
69
|
4 |
|
$this->registry->register('isSecureArea', true); |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
4 |
|
foreach ($optionFixtures as $optionFixture) { |
|
72
|
4 |
|
$this->attributeOptionManagement->delete( |
|
73
|
4 |
|
Product::ENTITY, |
|
|
|
|
|
|
74
|
4 |
|
$optionFixture->getAttributeCode(), |
|
75
|
4 |
|
$optionFixture->getOption()->getId() |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
4 |
|
$this->registry->unregister('isSecureArea'); |
|
|
|
|
|
|
80
|
4 |
|
} |
|
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