|
7 | 7 |
|
8 | 8 | namespace Magento\Store\Test\Unit\Model;
|
9 | 9 |
|
10 |
| -use Magento\Config\Model\ResourceModel\Config\Data; |
11 |
| -use Magento\Framework\Api\AttributeValueFactory; |
12 |
| -use Magento\Framework\Api\ExtensionAttributesFactory; |
13 |
| -use Magento\Framework\Data\Collection\AbstractDb; |
14 |
| -use Magento\Framework\Event\ManagerInterface; |
15 |
| -use Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface; |
16 |
| -use Magento\Framework\Model\Context; |
17 |
| -use Magento\Framework\Model\ResourceModel\AbstractResource; |
18 |
| -use Magento\Framework\Registry; |
| 10 | +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
19 | 11 | use Magento\Store\Model\Group;
|
20 |
| -use Magento\Store\Model\ResourceModel\Store\CollectionFactory; |
21 |
| -use Magento\Store\Model\StoreManagerInterface; |
22 |
| -use Magento\Store\Model\Validation\StoreValidator; |
23 |
| -use PHPUnit\Framework\MockObject\MockObject; |
24 | 12 | use PHPUnit\Framework\TestCase;
|
25 | 13 |
|
26 |
| -/** |
27 |
| - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
28 |
| - */ |
29 | 14 | class GroupTest extends TestCase
|
30 | 15 | {
|
31 | 16 | /**
|
32 |
| - * @var Group|MockObject |
33 |
| - */ |
34 |
| - private $model; |
35 |
| - |
36 |
| - /** |
37 |
| - * @var Context|MockObject |
38 |
| - */ |
39 |
| - private $context; |
40 |
| - |
41 |
| - /** |
42 |
| - * @var Registry|MockObject |
43 |
| - */ |
44 |
| - private $registry; |
45 |
| - |
46 |
| - /** |
47 |
| - * @var ExtensionAttributesFactory|MockObject |
48 |
| - */ |
49 |
| - private $extensionFactory; |
50 |
| - |
51 |
| - /** |
52 |
| - * @var AttributeValueFactory|MockObject |
53 |
| - */ |
54 |
| - private $customAttributeFactory; |
55 |
| - |
56 |
| - /** |
57 |
| - * @var Data|MockObject |
58 |
| - */ |
59 |
| - private $configDataResource; |
60 |
| - |
61 |
| - /** |
62 |
| - * @var CollectionFactory|MockObject |
63 |
| - */ |
64 |
| - private $storeListFactory; |
65 |
| - |
66 |
| - /** |
67 |
| - * @var StoreManagerInterface|MockObject |
| 17 | + * @var Group |
68 | 18 | */
|
69 |
| - private $storeManager; |
| 19 | + protected $model; |
70 | 20 |
|
71 | 21 | /**
|
72 |
| - * @var AbstractResource|MockObject |
| 22 | + * @var ObjectManager |
73 | 23 | */
|
74 |
| - private $resource; |
75 |
| - |
76 |
| - /** |
77 |
| - * @var AbstractDb|MockObject |
78 |
| - */ |
79 |
| - private $resourceCollection; |
80 |
| - |
81 |
| - /** |
82 |
| - * @var ManagerInterface|MockObject |
83 |
| - */ |
84 |
| - private $eventManager; |
85 |
| - |
86 |
| - /** |
87 |
| - * @var PoisonPillPutInterface|MockObject |
88 |
| - */ |
89 |
| - private $pillPut; |
90 |
| - |
91 |
| - /** |
92 |
| - * @var StoreValidator|MockObject |
93 |
| - */ |
94 |
| - private $modelValidator; |
| 24 | + protected $objectManagerHelper; |
95 | 25 |
|
96 | 26 | protected function setUp(): void
|
97 | 27 | {
|
98 |
| - $this->context = $this->getMockBuilder(Context::class) |
99 |
| - ->disableOriginalConstructor() |
100 |
| - ->getMock(); |
101 |
| - |
102 |
| - $this->registry = $this->getMockBuilder(Registry::class) |
103 |
| - ->disableOriginalConstructor() |
104 |
| - ->getMock(); |
105 |
| - |
106 |
| - $this->extensionFactory = $this->getMockBuilder(ExtensionAttributesFactory::class) |
107 |
| - ->disableOriginalConstructor() |
108 |
| - ->getMock(); |
109 |
| - |
110 |
| - $this->customAttributeFactory = $this->getMockBuilder(AttributeValueFactory::class) |
111 |
| - ->disableOriginalConstructor() |
112 |
| - ->getMock(); |
113 |
| - |
114 |
| - $this->configDataResource = $this->getMockBuilder(Data::class) |
115 |
| - ->disableOriginalConstructor() |
116 |
| - ->getMock(); |
117 |
| - |
118 |
| - $this->storeListFactory = $this->getMockBuilder(CollectionFactory::class) |
119 |
| - ->disableOriginalConstructor() |
120 |
| - ->getMock(); |
121 |
| - |
122 |
| - $this->storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class); |
123 |
| - |
124 |
| - $this->resource = $this->getMockBuilder(AbstractResource::class) |
125 |
| - ->addMethods(['getIdFieldName']) |
126 |
| - ->disableOriginalConstructor() |
127 |
| - ->getMockForAbstractClass(); |
128 |
| - |
129 |
| - $this->resourceCollection = $this->getMockBuilder(AbstractDb::class) |
130 |
| - ->disableOriginalConstructor() |
131 |
| - ->getMock(); |
132 |
| - |
133 |
| - $this->eventManager = $this->getMockForAbstractClass(ManagerInterface::class); |
134 |
| - |
135 |
| - $this->pillPut = $this->getMockForAbstractClass(PoisonPillPutInterface::class); |
136 |
| - |
137 |
| - $this->modelValidator = $this->getMockBuilder(StoreValidator::class) |
138 |
| - ->disableOriginalConstructor() |
139 |
| - ->getMock(); |
| 28 | + $this->objectManagerHelper = new ObjectManager($this); |
140 | 29 |
|
141 |
| - $this->model = new Group( |
142 |
| - $this->context, |
143 |
| - $this->registry, |
144 |
| - $this->extensionFactory, |
145 |
| - $this->customAttributeFactory, |
146 |
| - $this->configDataResource, |
147 |
| - $this->storeListFactory, |
148 |
| - $this->storeManager, |
149 |
| - $this->resource, |
150 |
| - $this->resourceCollection, |
151 |
| - [], |
152 |
| - $this->eventManager, |
153 |
| - $this->pillPut, |
154 |
| - $this->modelValidator |
| 30 | + $this->model = $this->objectManagerHelper->getObject( |
| 31 | + Group::class |
155 | 32 | );
|
156 | 33 | }
|
157 | 34 |
|
|
0 commit comments