Skip to content

Commit 94f8ea3

Browse files
authored
Merge pull request #5817 from magento-tsg/2.4-develop-com-int-improve-pr2
[TSG-Commerce] 2.4 Inegration tests improvment PR2
2 parents c43d763 + 305406a commit 94f8ea3

File tree

44 files changed

+1211
-34
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1211
-34
lines changed

dev/tests/api-functional/_files/Magento/TestModuleOverrideConfig3/Test/Api/_files/overrides.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,44 @@
4343
</dataSet>
4444
</method>
4545
</test>
46+
<test class="Magento\TestModuleOverrideConfig\Inheritance\Fixtures\FixturesInterface">
47+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_1" value="overridden config fixture value for class"/>
48+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php"/>
49+
<method name="testInterfaceInheritance">
50+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_2" newValue="overridden config fixture value for method"/>
51+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php" newPath="Magento/TestModuleOverrideConfig2/_files/fixture2_second_module.php" />
52+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture2_first_module_rollback.php" newPath="Magento/TestModuleOverrideConfig2/_files/fixture2_second_module_rollback.php" />
53+
<dataSet name="second_data_set">
54+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_3" remove="true"/>
55+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php" remove="true"/>
56+
</dataSet>
57+
</method>
58+
</test>
59+
<test class="Magento\TestModuleOverrideConfig\Inheritance\Fixtures\FixturesAbstractClass">
60+
<method name="testAbstractInheritance">
61+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_2" remove="true"/>
62+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php" remove="true"/>
63+
<dataSet name="first_data_set">
64+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_3" value="overridden config fixture value for data set from abstract"/>
65+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php"/>
66+
</dataSet>
67+
<dataSet name="second_data_set">
68+
<magentoConfigFixture scopeType="store" scopeCode="default" path="test_section/test_group/field_1" newValue="overridden config fixture value for data set from abstract"/>
69+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php" newPath="Magento/TestModuleOverrideConfig2/_files/fixture1_second_module.php" />
70+
<magentoApiDataFixture path="Magento/TestModuleOverrideConfig/_files/fixture1_first_module_rollback.php" newPath="Magento/TestModuleOverrideConfig2/_files/fixture1_second_module_rollback.php" />
71+
</dataSet>
72+
</method>
73+
</test>
74+
<test class="Magento\TestModuleOverrideConfig\Inheritance\Skip\SkipAbstractClass">
75+
<method name="testAbstractSkip" skip="true"/>
76+
<method name="testSkipDataSet">
77+
<dataSet name="first_data_set" skip="true"/>
78+
</method>
79+
</test>
80+
<test class="Magento\TestModuleOverrideConfig\Inheritance\Skip\SkipInterface">
81+
<method name="testInterfaceSkip" skip="true"/>
82+
<method name="testSkipDataSet">
83+
<dataSet name="second_data_set" skip="true"/>
84+
</method>
85+
</test>
4686
</overrides>

dev/tests/api-functional/framework/Magento/TestFramework/WebapiWorkaround/Override/Config.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
use Magento\Framework\Config\ConverterInterface;
1212
use Magento\Framework\Config\SchemaLocatorInterface;
1313
use Magento\Framework\View\File\CollectorInterface;
14+
use Magento\TestFramework\Annotation\AdminConfigFixture;
15+
use Magento\TestFramework\Annotation\ApiConfigFixture;
16+
use Magento\TestFramework\Annotation\ApiDataFixture;
17+
use Magento\TestFramework\Annotation\DataFixture;
18+
use Magento\TestFramework\Annotation\DataFixtureBeforeTransaction;
1419
use Magento\TestFramework\WebapiWorkaround\Override\Config\Converter;
1520
use Magento\TestFramework\WebapiWorkaround\Override\Config\FileCollector;
1621
use Magento\TestFramework\WebapiWorkaround\Override\Config\SchemaLocator;
@@ -21,12 +26,23 @@
2126
*/
2227
class Config extends IntegrationConfig
2328
{
29+
/**
30+
* @inheritdoc
31+
*/
32+
protected const FIXTURE_TYPES = [
33+
ApiDataFixture::ANNOTATION,
34+
ApiConfigFixture::ANNOTATION,
35+
DataFixture::ANNOTATION,
36+
DataFixtureBeforeTransaction::ANNOTATION,
37+
AdminConfigFixture::ANNOTATION,
38+
];
39+
2440
/**
2541
* @inheritdoc
2642
*/
2743
protected function getConverter(): ConverterInterface
2844
{
29-
return ObjectManager::getInstance()->create(Converter::class);
45+
return ObjectManager::getInstance()->create(Converter::class, ['types' => $this::FIXTURE_TYPES]);
3046
}
3147

3248
/**

dev/tests/api-functional/framework/Magento/TestFramework/WebapiWorkaround/Override/Config/Converter.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\TestFramework\WebapiWorkaround\Override\Config;
99

1010
use Magento\TestFramework\Annotation\AdminConfigFixture;
11-
use Magento\TestFramework\Annotation\ApiConfigFixture;
1211
use Magento\TestFramework\Annotation\ApiDataFixture;
1312
use Magento\TestFramework\Annotation\ConfigFixture;
1413
use Magento\TestFramework\Annotation\DataFixture;
@@ -20,14 +19,6 @@
2019
*/
2120
class Converter extends IntegrationConverter
2221
{
23-
protected const FIXTURE_TYPES = [
24-
ApiDataFixture::ANNOTATION,
25-
ApiConfigFixture::ANNOTATION,
26-
DataFixture::ANNOTATION,
27-
DataFixtureBeforeTransaction::ANNOTATION,
28-
AdminConfigFixture::ANNOTATION,
29-
];
30-
3122
/**
3223
* Fill node attributes values
3324
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
9+
10+
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
11+
12+
/**
13+
* Test abstract class for testing fixtures override config inheritance.
14+
*
15+
* phpcs:disable Generic.Classes.DuplicateClassName
16+
*/
17+
abstract class FixturesAbstractClass extends AbstractOverridesTest
18+
{
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
9+
10+
/**
11+
* Test interface for testing fixtures override config inheritance.
12+
*
13+
* phpcs:disable Generic.Classes.DuplicateClassName
14+
*/
15+
interface FixturesInterface
16+
{
17+
18+
}
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestModuleOverrideConfig\Inheritance\Fixtures;
9+
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
use Magento\Store\Model\ScopeInterface;
12+
use Magento\TestFramework\Config\Model\ConfigStorage;
13+
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
14+
15+
/**
16+
* Class checks that fixtures override config inherited from abstract class and interface.
17+
*
18+
* phpcs:disable Generic.Classes.DuplicateClassName
19+
*
20+
* @magentoAppIsolation enabled
21+
*/
22+
class FixturesTest extends FixturesAbstractClass implements FixturesInterface
23+
{
24+
/**
25+
* @var ScopeConfigInterface
26+
*/
27+
private $config;
28+
29+
/**
30+
* @var ConfigStorage
31+
*/
32+
private $configStorage;
33+
34+
/**
35+
* @var FixtureCallStorage
36+
*/
37+
private $fixtureCallStorage;
38+
39+
/**
40+
* @inheritdoc
41+
*/
42+
protected function setUp(): void
43+
{
44+
parent::setUp();
45+
46+
$this->config = $this->objectManager->get(ScopeConfigInterface::class);
47+
$this->configStorage = $this->objectManager->get(ConfigStorage::class);
48+
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
49+
}
50+
51+
/**
52+
* @magentoConfigFixture default_store test_section/test_group/field_2 new_value
53+
* @magentoConfigFixture default_store test_section/test_group/field_3 new_value
54+
* @magentoApiDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
55+
* @magentoApiDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
56+
* @dataProvider interfaceDataProvider
57+
* @param array $storeConfigs
58+
* @param array $fixtures
59+
* @return void
60+
*/
61+
public function testInterfaceInheritance(
62+
array $storeConfigs,
63+
array $fixtures
64+
): void {
65+
$this->assertConfigFieldValues($storeConfigs, ScopeInterface::SCOPE_STORES);
66+
$this->assertUsedFixturesCount($fixtures);
67+
}
68+
69+
/**
70+
* @magentoConfigFixture default_store test_section/test_group/field_2 new_value
71+
* @magentoApiDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
72+
* @dataProvider abstractDataProvider
73+
* @param array $storeConfigs
74+
* @param array $fixtures
75+
* @return void
76+
*/
77+
public function testAbstractInheritance(
78+
array $storeConfigs,
79+
array $fixtures
80+
): void {
81+
$this->assertConfigFieldValues($storeConfigs, ScopeInterface::SCOPE_STORES);
82+
$this->assertUsedFixturesCount($fixtures);
83+
}
84+
85+
/**
86+
* @return array
87+
*/
88+
public function interfaceDataProvider(): array
89+
{
90+
return [
91+
'first_data_set' => [
92+
'store_configs' => [
93+
'test_section/test_group/field_1' => [
94+
'value' => 'overridden config fixture value for class',
95+
'exists_in_db' => true,
96+
],
97+
'test_section/test_group/field_2' => [
98+
'value' => 'overridden config fixture value for method',
99+
'exists_in_db' => true,
100+
],
101+
'test_section/test_group/field_3' => [
102+
'value' => 'new_value',
103+
'exists_in_db' => true,
104+
],
105+
],
106+
'fixtures' => [
107+
'fixture1_first_module.php' => 1,
108+
'fixture2_first_module.php' => 0,
109+
'fixture2_second_module.php' => 1,
110+
'fixture3_first_module.php' => 1,
111+
],
112+
],
113+
'second_data_set' => [
114+
'store_configs' => [
115+
'test_section/test_group/field_1' => [
116+
'value' => 'overridden config fixture value for class',
117+
'exists_in_db' => true,
118+
],
119+
'test_section/test_group/field_2' => [
120+
'value' => 'overridden config fixture value for method',
121+
'exists_in_db' => true,
122+
],
123+
'test_section/test_group/field_3' => [
124+
'value' => '3rd field website scope default value',
125+
'exists_in_db' => false,
126+
],
127+
],
128+
'fixtures' => [
129+
'fixture1_first_module.php' => 1,
130+
'fixture2_first_module.php' => 0,
131+
'fixture2_second_module.php' => 1,
132+
'fixture3_first_module.php' => 0,
133+
],
134+
],
135+
];
136+
}
137+
138+
/**
139+
* @return array
140+
*/
141+
public function abstractDataProvider(): array
142+
{
143+
return [
144+
'first_data_set' => [
145+
'store_configs' => [
146+
'test_section/test_group/field_1' => [
147+
'value' => 'overridden config fixture value for class',
148+
'exists_in_db' => true,
149+
],
150+
'test_section/test_group/field_2' => [
151+
'value' => '2nd field default value',
152+
'exists_in_db' => false,
153+
],
154+
'test_section/test_group/field_3' => [
155+
'value' => 'overridden config fixture value for data set from abstract',
156+
'exists_in_db' => true,
157+
],
158+
],
159+
'fixtures' => [
160+
'fixture1_first_module.php' => 1,
161+
'fixture2_first_module.php' => 0,
162+
'fixture2_second_module.php' => 0,
163+
'fixture3_first_module.php' => 1,
164+
],
165+
],
166+
'second_data_set' => [
167+
'store_configs' => [
168+
'test_section/test_group/field_1' => [
169+
'value' => 'overridden config fixture value for data set from abstract',
170+
'exists_in_db' => true,
171+
],
172+
'test_section/test_group/field_2' => [
173+
'value' => '2nd field default value',
174+
'exists_in_db' => false,
175+
],
176+
'test_section/test_group/field_3' => [
177+
'value' => '3rd field website scope default value',
178+
'exists_in_db' => false,
179+
],
180+
],
181+
'fixtures' => [
182+
'fixture1_first_module.php' => 0,
183+
'fixture2_first_module.php' => 0,
184+
'fixture1_second_module.php' => 1,
185+
'fixture3_first_module.php' => 0,
186+
],
187+
],
188+
];
189+
}
190+
191+
/**
192+
* Asserts config field values.
193+
*
194+
* @param array $configs
195+
* @param string $scope
196+
* @return void
197+
*/
198+
private function assertConfigFieldValues(
199+
array $configs,
200+
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
201+
): void {
202+
foreach ($configs as $path => $expected) {
203+
$this->assertEquals($expected['value'], $this->config->getValue($path, $scope, 'default'));
204+
if ($expected['exists_in_db']) {
205+
$this->assertEquals(
206+
$expected['value'],
207+
$this->configStorage->getValueFromDb($path, ScopeInterface::SCOPE_STORES, 'default')
208+
);
209+
} else {
210+
$this->assertFalse(
211+
$this->configStorage->checkIsRecordExist($path, ScopeInterface::SCOPE_STORES, 'default')
212+
);
213+
}
214+
}
215+
}
216+
217+
/**
218+
* Asserts count of used fixtures.
219+
*
220+
* @param array $fixtures
221+
* @return void
222+
*/
223+
private function assertUsedFixturesCount(array $fixtures): void
224+
{
225+
foreach ($fixtures as $fixture => $count) {
226+
$this->assertEquals($count, $this->fixtureCallStorage->getFixturesCount($fixture));
227+
}
228+
}
229+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TestModuleOverrideConfig\Inheritance\Skip;
9+
10+
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
11+
12+
/**
13+
* Test abstract class for testing skip override config inheritance.
14+
*
15+
* phpcs:disable Generic.Classes.DuplicateClassName
16+
*/
17+
abstract class SkipAbstractClass extends AbstractOverridesTest
18+
{
19+
20+
}

0 commit comments

Comments
 (0)