Skip to content

Commit a715bdb

Browse files
author
Oleksandr Iegorov
committed
Merge branch '2.4.3-develop' of https://github.com/magento/magento2ce into MC-42420
2 parents a1ec248 + fb69d67 commit a715bdb

27 files changed

+696
-363
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/MassDeleteTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,19 @@ protected function dispatchMassDeleteAction(array $productIds = []): void
151151
$this->getRequest()->setParams(['selected' => $productIds, 'namespace' => 'product_listing']);
152152
$this->dispatch('backend/catalog/product/massDelete/');
153153
}
154+
155+
/**
156+
* @inheritDoc
157+
*/
158+
protected function tearDown(): void
159+
{
160+
parent::tearDown();
161+
$reflection = new \ReflectionObject($this);
162+
foreach ($reflection->getProperties() as $property) {
163+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
164+
$property->setAccessible(true);
165+
$property->setValue($this, null);
166+
}
167+
}
168+
}
154169
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/CreateCustomOptionsTest.php

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,6 @@ class CreateCustomOptionsTest extends AbstractBackendController
2828
*/
2929
protected $productSku = 'simple';
3030

31-
/**
32-
* @var ProductRepositoryInterface
33-
*/
34-
private $productRepository;
35-
36-
/**
37-
* @var ProductCustomOptionRepositoryInterface
38-
*/
39-
private $optionRepository;
40-
41-
/**
42-
* @inheritDoc
43-
*/
44-
protected function setUp(): void
45-
{
46-
parent::setUp();
47-
48-
$this->productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
49-
$this->optionRepository = $this->_objectManager->create(ProductCustomOptionRepositoryInterface::class);
50-
}
51-
5231
/**
5332
* Test add to product custom option with type "field".
5433
*
@@ -61,14 +40,15 @@ protected function setUp(): void
6140
public function testSaveCustomOptionWithTypeField(array $productPostData): void
6241
{
6342
$this->getRequest()->setPostValue($productPostData);
64-
$product = $this->productRepository->get($this->productSku);
43+
$product = $this->_objectManager->get(ProductRepositoryInterface::class)->get($this->productSku);
6544
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
6645
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
6746
$this->assertSessionMessages(
6847
$this->containsEqual('You saved the product.'),
6948
MessageInterface::TYPE_SUCCESS
7049
);
71-
$productOptions = $this->optionRepository->getProductOptions($product);
50+
$productOptions = $this->_objectManager->get(ProductCustomOptionRepositoryInterface::class)
51+
->getProductOptions($product);
7252
$this->assertCount(2, $productOptions);
7353
foreach ($productOptions as $customOption) {
7454
$postOptionData = $productPostData['product']['options'][$customOption->getTitle()] ?? null;
@@ -274,4 +254,19 @@ public function productWithNewOptionsDataProvider(): array
274254
],
275255
];
276256
}
257+
258+
/**
259+
* @inheritDoc
260+
*/
261+
protected function tearDown(): void
262+
{
263+
parent::tearDown();
264+
$reflection = new \ReflectionObject($this);
265+
foreach ($reflection->getProperties() as $property) {
266+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
267+
$property->setAccessible(true);
268+
$property->setValue($this, null);
269+
}
270+
}
271+
}
277272
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/DeleteCustomOptionsTest.php

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,6 @@ class DeleteCustomOptionsTest extends AbstractBackendController
3030
*/
3131
protected $productSku = 'simple';
3232

33-
/**
34-
* @var ProductRepositoryInterface
35-
*/
36-
private $productRepository;
37-
38-
/**
39-
* @var ProductCustomOptionRepositoryInterface
40-
*/
41-
private $optionRepository;
42-
43-
/**
44-
* @var ProductCustomOptionInterfaceFactory
45-
*/
46-
private $optionRepositoryFactory;
47-
48-
/**
49-
* @inheritdoc
50-
*/
51-
protected function setUp(): void
52-
{
53-
parent::setUp();
54-
55-
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
56-
$this->optionRepository = $this->_objectManager->get(ProductCustomOptionRepositoryInterface::class);
57-
$this->optionRepositoryFactory = $this->_objectManager->get(ProductCustomOptionInterfaceFactory::class);
58-
}
5933

6034
/**
6135
* Test delete custom option with type "field".
@@ -67,18 +41,39 @@ protected function setUp(): void
6741
*/
6842
public function testDeleteCustomOptionWithTypeField(array $optionData): void
6943
{
70-
$product = $this->productRepository->get($this->productSku);
44+
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
45+
$product = $productRepository->get($this->productSku);
7146
/** @var ProductCustomOptionInterface $option */
72-
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
47+
$option = $this->_objectManager->get(ProductCustomOptionInterfaceFactory::class)
48+
->create(['data' => $optionData]);
7349
$option->setProductSku($product->getSku());
7450
$product->setOptions([$option]);
75-
$this->productRepository->save($product);
51+
$productRepository->save($product);
7652
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
7753
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
7854
$this->assertSessionMessages(
7955
$this->equalTo([(string)__('You saved the product.')]),
8056
MessageInterface::TYPE_SUCCESS
8157
);
82-
$this->assertCount(0, $this->optionRepository->getProductOptions($product));
58+
$this->assertCount(
59+
0,
60+
$this->_objectManager->get(ProductCustomOptionRepositoryInterface::class)
61+
->getProductOptions($product)
62+
);
63+
}
64+
65+
/**
66+
* @inheritDoc
67+
*/
68+
protected function tearDown(): void
69+
{
70+
parent::tearDown();
71+
$reflection = new \ReflectionObject($this);
72+
foreach ($reflection->getProperties() as $property) {
73+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
74+
$property->setAccessible(true);
75+
$property->setValue($this, null);
76+
}
77+
}
8378
}
8479
}

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,6 @@ class UpdateCustomOptionsTest extends AbstractBackendController
3131
*/
3232
protected $productSku = 'simple';
3333

34-
/**
35-
* @var ProductRepositoryInterface
36-
*/
37-
private $productRepository;
38-
39-
/**
40-
* @var ProductCustomOptionRepositoryInterface
41-
*/
42-
private $optionRepository;
43-
44-
/**
45-
* @var ProductCustomOptionInterfaceFactory
46-
*/
47-
private $optionRepositoryFactory;
48-
49-
/**
50-
* @inheritdoc
51-
*/
52-
protected function setUp(): void
53-
{
54-
parent::setUp();
55-
56-
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
57-
$this->optionRepository = $this->_objectManager->get(ProductCustomOptionRepositoryInterface::class);
58-
$this->optionRepositoryFactory = $this->_objectManager->get(ProductCustomOptionInterfaceFactory::class);
59-
}
60-
6134
/**
6235
* Test add to product custom option with type "field".
6336
*
@@ -69,13 +42,16 @@ protected function setUp(): void
6942
*/
7043
public function testUpdateCustomOptionWithTypeField(array $optionData, array $updateData): void
7144
{
72-
$product = $this->productRepository->get($this->productSku);
45+
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
46+
$optionRepository = $this->_objectManager->get(ProductCustomOptionRepositoryInterface::class);
47+
$product = $productRepository->get($this->productSku);
7348
/** @var ProductCustomOptionInterface|Option $option */
74-
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
49+
$option = $this->_objectManager->get(ProductCustomOptionInterfaceFactory::class)
50+
->create(['data' => $optionData]);
7551
$option->setProductSku($product->getSku());
7652
$product->setOptions([$option]);
77-
$this->productRepository->save($product);
78-
$currentProductOptions = $this->optionRepository->getProductOptions($product);
53+
$productRepository->save($product);
54+
$currentProductOptions = $optionRepository->getProductOptions($product);
7955
$this->assertCount(1, $currentProductOptions);
8056
/** @var ProductCustomOptionInterface $currentOption */
8157
$currentOption = reset($currentProductOptions);
@@ -119,7 +95,7 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
11995
$this->containsEqual('You saved the product.'),
12096
MessageInterface::TYPE_SUCCESS
12197
);
122-
$updatedOptions = $this->optionRepository->getProductOptions($product);
98+
$updatedOptions = $optionRepository->getProductOptions($product);
12399
$this->assertCount(1, $updatedOptions);
124100
/** @var ProductCustomOptionInterface|Option $updatedOption */
125101
$updatedOption = reset($updatedOptions);
@@ -131,4 +107,19 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
131107
);
132108
}
133109
}
110+
111+
/**
112+
* @inheritDoc
113+
*/
114+
protected function tearDown(): void
115+
{
116+
parent::tearDown();
117+
$reflection = new \ReflectionObject($this);
118+
foreach ($reflection->getProperties() as $property) {
119+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
120+
$property->setAccessible(true);
121+
$property->setValue($this, null);
122+
}
123+
}
124+
}
134125
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,15 @@
2222
*/
2323
class CreateOptionsTest extends AbstractBackendController
2424
{
25-
/** @var ProductRepositoryInterface */
26-
private $productRepository;
27-
28-
/** @var SerializerInterface */
29-
private $json;
30-
31-
/** @var ProductAttributeRepositoryInterface */
32-
private $attributeRepository;
33-
3425
/**
3526
* @inheritdoc
3627
*/
3728
protected function setUp(): void
3829
{
3930
parent::setUp();
4031

41-
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
42-
$this->productRepository->cleanCache();
43-
$this->json = $this->_objectManager->get(SerializerInterface::class);
44-
$this->attributeRepository = $this->_objectManager->get(ProductAttributeRepositoryInterface::class);
32+
$productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
33+
$productRepository->cleanCache();
4534
}
4635

4736
/**
@@ -52,7 +41,8 @@ protected function setUp(): void
5241
public function testAddAlreadyAddedOption(): void
5342
{
5443
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
55-
$attribute = $this->attributeRepository->get('test_configurable');
44+
$attribute = $this->_objectManager->get(ProductAttributeRepositoryInterface::class)
45+
->get('test_configurable');
5646
$this->getRequest()->setParams([
5747
'options' => [
5848
[
@@ -63,11 +53,27 @@ public function testAddAlreadyAddedOption(): void
6353
],
6454
]);
6555
$this->dispatch('backend/catalog/product_attribute/createOptions');
66-
$responseBody = $this->json->unserialize($this->getResponse()->getBody());
56+
$responseBody = $this->_objectManager->get(SerializerInterface::class)
57+
->unserialize($this->getResponse()->getBody());
6758
$this->assertNotEmpty($responseBody);
6859
$this->assertStringContainsString(
6960
(string)__('The value of attribute ""%1"" must be unique', $attribute->getAttributeCode()),
7061
$responseBody['message']
7162
);
7263
}
64+
65+
/**
66+
* @inheritDoc
67+
*/
68+
protected function tearDown(): void
69+
{
70+
parent::tearDown();
71+
$reflection = new \ReflectionObject($this);
72+
foreach ($reflection->getProperties() as $property) {
73+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
74+
$property->setAccessible(true);
75+
$property->setValue($this, null);
76+
}
77+
}
78+
}
7379
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ protected function setUp(): void
9696
parent::setUp();
9797
$this->objectManager = Bootstrap::getObjectManager();
9898
$this->request = $this->objectManager->get(RequestInterface::class);
99-
$this->helper = $this->objectManager->create(Helper::class);
99+
$this->helper = $this->objectManager->get(Helper::class);
100100
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
101101
$this->productRepository->cleanCache();
102102
$this->productResource =$this->objectManager->get(ProductResource::class);
103-
$this->productAttributeRepository = $this->objectManager->create(ProductAttributeRepositoryInterface::class);
103+
$this->productAttributeRepository = $this->objectManager->get(ProductAttributeRepositoryInterface::class);
104104
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
105105
$this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
106106
$this->config = $this->objectManager->get(Config::class);
@@ -366,4 +366,19 @@ private function updateChildProductsImages(array $imageNames): void
366366
$this->productResource->save($simpleProduct);
367367
}
368368
}
369+
370+
/**
371+
* @inheritDoc
372+
*/
373+
protected function tearDown(): void
374+
{
375+
parent::tearDown();
376+
$reflection = new \ReflectionObject($this);
377+
foreach ($reflection->getProperties() as $property) {
378+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
379+
$property->setAccessible(true);
380+
$property->setValue($this, null);
381+
}
382+
}
383+
}
369384
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function setUp(): void
6464
parent::setUp();
6565
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
6666
$this->productRepository->cleanCache();
67-
$this->productAttributeRepository = $this->_objectManager->create(ProductAttributeRepositoryInterface::class);
67+
$this->productAttributeRepository = $this->_objectManager->get(ProductAttributeRepositoryInterface::class);
6868
$this->registry = $this->_objectManager->get(Registry::class);
6969
$this->jsonSerializer = $this->_objectManager->get(SerializerInterface::class);
7070
$this->eavConfig = $this->_objectManager->get(Config::class);
@@ -519,4 +519,19 @@ private function getProductIds(array $skuList): array
519519

520520
return $associatedProductIds;
521521
}
522+
523+
/**
524+
* @inheritDoc
525+
*/
526+
protected function tearDown(): void
527+
{
528+
parent::tearDown();
529+
$reflection = new \ReflectionObject($this);
530+
foreach ($reflection->getProperties() as $property) {
531+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
532+
$property->setAccessible(true);
533+
$property->setValue($this, null);
534+
}
535+
}
536+
}
522537
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,19 @@ public function testExecuteForConfigurableLastOption()
9898
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
9999
);
100100
}
101+
102+
/**
103+
* @inheritDoc
104+
*/
105+
protected function tearDown(): void
106+
{
107+
parent::tearDown();
108+
$reflection = new \ReflectionObject($this);
109+
foreach ($reflection->getProperties() as $property) {
110+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
111+
$property->setAccessible(true);
112+
$property->setValue($this, null);
113+
}
114+
}
115+
}
101116
}

0 commit comments

Comments
 (0)