Skip to content

Commit 2226143

Browse files
committed
MC-42430: Integration B2B test runs Jenkins agent out of memory
1 parent c997c53 commit 2226143

16 files changed

+501
-260
lines changed

dev/tests/integration/testsuite/Magento/Eav/Model/ConfigTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,19 @@ public function testGetAttributeWithInitUserDefinedAttribute()
189189
$updatedAttributeAfterCacheClean = $config->getAttribute($entityType, 'foo');
190190
$this->assertEquals('bar', $updatedAttributeAfterCacheClean->getFrontendLabel());
191191
}
192+
193+
/**
194+
* @inheritDoc
195+
*/
196+
protected function tearDown(): void
197+
{
198+
parent::tearDown();
199+
$reflection = new \ReflectionObject($this);
200+
foreach ($reflection->getProperties() as $property) {
201+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
202+
$property->setAccessible(true);
203+
$property->setValue($this, null);
204+
}
205+
}
206+
}
192207
}

dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DatetimeTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,19 @@ public function testFrontendValueOnDifferentWebsites(): void
101101
'The difference between values per different timezones is incorrect'
102102
);
103103
}
104+
105+
/**
106+
* @inheritDoc
107+
*/
108+
protected function tearDown(): void
109+
{
110+
parent::tearDown();
111+
$reflection = new \ReflectionObject($this);
112+
foreach ($reflection->getProperties() as $property) {
113+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
114+
$property->setAccessible(true);
115+
$property->setValue($this, null);
116+
}
117+
}
118+
}
104119
}

dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Eav\Model\Entity\Attribute\Frontend;
77

8+
use Magento\Catalog\Model\Product;
89
use Magento\TestFramework\Helper\Bootstrap;
910
use Magento\TestFramework\Helper\CacheCleaner;
1011
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
@@ -82,7 +83,7 @@ public function testGetSelectOptions()
8283
*/
8384
public function testAttributeEntityValueNotSet()
8485
{
85-
$entity = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
86+
$entity = $this->objectManager->create(Product::class);
8687
$entity->setStoreId(0);
8788
$entity->load(1);
8889
$frontEnd = $this->attribute->loadByCode('catalog_product', 'dropdown_attribute');
@@ -100,4 +101,19 @@ private function getCacheKey()
100101
$this->defaultFrontend->getAttribute()->getAttributeCode() . '-' .
101102
$this->storeManager->getStore()->getId();
102103
}
104+
105+
/**
106+
* @inheritDoc
107+
*/
108+
protected function tearDown(): void
109+
{
110+
parent::tearDown();
111+
$reflection = new \ReflectionObject($this);
112+
foreach ($reflection->getProperties() as $property) {
113+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
114+
$property->setAccessible(true);
115+
$property->setValue($this, null);
116+
}
117+
}
118+
}
103119
}

dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeLoaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,19 @@ public function loadAllAttributesDataProvider()
109109
],
110110
];
111111
}
112+
113+
/**
114+
* @inheritDoc
115+
*/
116+
protected function tearDown(): void
117+
{
118+
parent::tearDown();
119+
$reflection = new \ReflectionObject($this);
120+
foreach ($reflection->getProperties() as $property) {
121+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
122+
$property->setAccessible(true);
123+
$property->setValue($this, null);
124+
}
125+
}
126+
}
112127
}

dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ protected function tearDown(): void
5050
$this->attribute = null;
5151
$this->objectManager = null;
5252
$this->localeResolver = null;
53+
54+
$reflection = new \ReflectionObject($this);
55+
foreach ($reflection->getProperties() as $property) {
56+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
57+
$property->setAccessible(true);
58+
$property->setValue($this, null);
59+
}
60+
}
5361
}
5462

5563
/**

dev/tests/integration/testsuite/Magento/Eav/Model/ResourceModel/AttributeLoaderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,19 @@ public function getAttributesDataProvider()
8181
]
8282
];
8383
}
84+
85+
/**
86+
* @inheritDoc
87+
*/
88+
protected function tearDown(): void
89+
{
90+
parent::tearDown();
91+
$reflection = new \ReflectionObject($this);
92+
foreach ($reflection->getProperties() as $property) {
93+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
94+
$property->setAccessible(true);
95+
$property->setValue($this, null);
96+
}
97+
}
98+
}
8499
}

dev/tests/integration/testsuite/Magento/Eav/Model/ResourceModel/Entity/Attribute/CollectionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,19 @@ public function testAddAttributeGrouping()
9393
$this->_model->addAttributeGrouping();
9494
$this->assertEquals(['main_table.attribute_id'], $select->getPart(\Magento\Framework\DB\Select::GROUP));
9595
}
96+
97+
/**
98+
* @inheritDoc
99+
*/
100+
protected function tearDown(): void
101+
{
102+
parent::tearDown();
103+
$reflection = new \ReflectionObject($this);
104+
foreach ($reflection->getProperties() as $property) {
105+
if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) {
106+
$property->setAccessible(true);
107+
$property->setValue($this, null);
108+
}
109+
}
110+
}
96111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Eav\Model\ResourceModel\UpdateHandler;
8+
9+
use Magento\Catalog\Model\Product;
10+
use Magento\Eav\Model\ResourceModel\UpdateHandler;
11+
use Magento\Eav\Model\ResourceModel\UpdateHandlerAbstract;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
/**
15+
* @magentoAppArea adminhtml
16+
* @magentoAppIsolation enabled
17+
*/
18+
class ExecuteProcessForAllStoresTest extends UpdateHandlerAbstract
19+
{
20+
/**
21+
* @covers \Magento\Eav\Model\ResourceModel\UpdateHandler::execute
22+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
23+
* @dataProvider getAllStoresDataProvider
24+
* @param $code
25+
* @param $snapshotValue
26+
* @param $newValue
27+
* @param $expected
28+
* @magentoDbIsolation disabled
29+
*/
30+
public function testExecuteProcessForAllStores($code, $snapshotValue, $newValue, $expected)
31+
{
32+
if ($snapshotValue !== '-') {
33+
$entity = Bootstrap::getObjectManager()->create(Product::class);
34+
$entity->setStoreId(0);
35+
$entity->load(1);
36+
$entity->setData($code, $snapshotValue);
37+
$entity->save();
38+
}
39+
40+
$entity = Bootstrap::getObjectManager()->create(Product::class);
41+
$entity->setStoreId(0);
42+
$entity->load(1);
43+
44+
$updateHandler = Bootstrap::getObjectManager()->create(UpdateHandler::class);
45+
$entityData = array_merge($entity->getData(), [$code => $newValue]);
46+
$updateHandler->execute(\Magento\Catalog\Api\Data\ProductInterface::class, $entityData);
47+
48+
$resultEntity = Bootstrap::getObjectManager()->create(Product::class);
49+
$resultEntity->setStoreId(0);
50+
$resultEntity->load(1);
51+
52+
$this->assertSame($expected, $resultEntity->getData($code));
53+
}
54+
55+
/**
56+
* @return array
57+
*/
58+
public function getAllStoresDataProvider()
59+
{
60+
return [
61+
['description', '', 'not_empty_value', 'not_empty_value'], //0
62+
['description', '', '', null], //1
63+
['description', '', null, null], //2
64+
['description', '', false, null], //3
65+
66+
['description', 'not_empty_value', 'not_empty_value2', 'not_empty_value2'], //4
67+
['description', 'not_empty_value', '', null], //5
68+
['description', 'not_empty_value', null, null], //6
69+
['description', 'not_empty_value', false, null], //7
70+
71+
['description', null, 'not_empty_value', 'not_empty_value'], //8
72+
['description', null, '', null], //9
73+
['description', null, false, null], //10
74+
75+
['description', false, 'not_empty_value', 'not_empty_value'], //11
76+
['description', false, '', null], //12
77+
['description', false, null, null], //13
78+
];
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Eav\Model\ResourceModel\UpdateHandler;
8+
9+
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\Eav\Model\ResourceModel\UpdateHandlerAbstract;
12+
use Magento\Store\Model\Store;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use Magento\Eav\Model\ResourceModel\UpdateHandler;
15+
16+
/**
17+
* @magentoAppArea adminhtml
18+
* @magentoAppIsolation enabled
19+
*/
20+
class ExecuteProcessForCustomAttributeInCustomStoreTest extends UpdateHandlerAbstract
21+
{
22+
/**
23+
* @covers \Magento\Eav\Model\ResourceModel\UpdateHandlerTest::execute
24+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
25+
* @magentoDataFixture Magento/Catalog/_files/dropdown_attribute.php
26+
* @magentoDataFixture Magento/Store/_files/second_store.php
27+
* @dataProvider getCustomAttributeDataProvider
28+
* @param $code
29+
* @param $defaultStoreValue
30+
* @param $snapshotValue
31+
* @param $newValue
32+
* @param $expected
33+
* @magentoDbIsolation disabled
34+
*/
35+
public function testExecuteProcessForCustomAttributeInCustomStore(
36+
$code,
37+
$defaultStoreValue,
38+
$snapshotValue,
39+
$newValue,
40+
$expected
41+
) {
42+
$store = Bootstrap::getObjectManager()->create(Store::class);
43+
$store->load('fixture_second_store', 'code');
44+
45+
$this->reindexAll();
46+
47+
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
48+
Attribute::class
49+
);
50+
$attribute->loadByCode(4, $code);
51+
52+
$options = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
53+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class
54+
);
55+
$options->setAttributeFilter($attribute->getId());
56+
$optionIds = $options->getAllIds();
57+
58+
$entity = Bootstrap::getObjectManager()->create(Product::class);
59+
$entity->setStoreId(0);
60+
$entity->load(1);
61+
$entity->setData($code, $optionIds[$defaultStoreValue]);
62+
$entity->save();
63+
64+
if ($snapshotValue !== '-') {
65+
/** @var $options \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */
66+
$entity = Bootstrap::getObjectManager()->create(Product::class);
67+
$entity->setStoreId($store->getId());
68+
$entity->load(1);
69+
70+
if ($snapshotValue) {
71+
$snapshotValue = $optionIds[$snapshotValue];
72+
}
73+
74+
$entity->setData($code, $snapshotValue);
75+
$entity->save();
76+
}
77+
78+
$entity = Bootstrap::getObjectManager()->create(Product::class);
79+
$entity->setStoreId($store->getId());
80+
$entity->load(1);
81+
82+
$updateHandler = Bootstrap::getObjectManager()->create(UpdateHandler::class);
83+
84+
if ($newValue) {
85+
$newValue = $optionIds[$newValue];
86+
}
87+
88+
$entityData = array_merge($entity->getData(), [$code => $newValue]);
89+
$updateHandler->execute(\Magento\Catalog\Api\Data\ProductInterface::class, $entityData);
90+
91+
$resultEntity = Bootstrap::getObjectManager()->create(Product::class);
92+
$resultEntity->setStoreId($store->getId());
93+
$resultEntity->load(1);
94+
95+
if ($expected !== null) {
96+
$expected = $optionIds[$expected];
97+
}
98+
99+
$this->assertSame($expected, $resultEntity->getData($code));
100+
}
101+
102+
103+
/**
104+
* @return array
105+
*/
106+
public function getCustomAttributeDataProvider()
107+
{
108+
return [
109+
['dropdown_attribute', 0, '', 1, 1], //0
110+
['dropdown_attribute', 0, '', '', null], //1
111+
['dropdown_attribute', 0, '', null, 0], //2
112+
['dropdown_attribute', 0, '', false, 0], //3
113+
114+
['dropdown_attribute', 0, 1, 2, 2], //4
115+
['dropdown_attribute', 0, 1, '', null], //5
116+
['dropdown_attribute', 0, 1, null, 0], //6
117+
['dropdown_attribute', 0, 1, false, 0], //7
118+
119+
['dropdown_attribute', 0, null, 1, 1], //8
120+
['dropdown_attribute', 0, null, '', null], //9
121+
['dropdown_attribute', 0, null, false, 0], //10
122+
123+
['dropdown_attribute', 0, false, 1, 1], //11
124+
['dropdown_attribute', 0, false, '', null], //12
125+
['dropdown_attribute', 0, false, null, 0], //13
126+
127+
['dropdown_attribute', 0, '-', 1, 1], //14
128+
['dropdown_attribute', 0, '-', '', null], //15
129+
['dropdown_attribute', 0, '-', null, 0], //16
130+
['dropdown_attribute', 0, '-', false, 0], //17
131+
];
132+
}
133+
}

0 commit comments

Comments
 (0)