Skip to content

Commit c11cf3f

Browse files
committed
MC-34459: Add global node to override config
1 parent bb176b8 commit c11cf3f

File tree

27 files changed

+193
-5
lines changed

27 files changed

+193
-5
lines changed

dev/tests/integration/_files/Magento/TestModuleOverrideConfig/etc/adminhtml/system.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<field id="field_1" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"/>
1313
<field id="field_2" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"/>
1414
<field id="field_3" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"/>
15+
<field id="field_4" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"/>
16+
<field id="field_5" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"/>
1517
</group>
1618
</section>
1719
</system>

dev/tests/integration/_files/Magento/TestModuleOverrideConfig/etc/config.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<field_1>1st field default value</field_1>
1313
<field_2>2nd field default value</field_2>
1414
<field_3>3rd field default value</field_3>
15+
<field_4>4th field default value</field_4>
16+
<field_5>5th field default value</field_5>
1517
</test_group>
1618
</test_section>
1719
</default>

dev/tests/integration/_files/Magento/TestModuleOverrideConfig2/Test/Integration/_files/overrides.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,9 @@
204204
<dataSet name="first_data_set" skip="true"/>
205205
</method>
206206
</test>
207+
<global>
208+
<magentoDataFixture path="Magento/TestModuleOverrideConfig/_files/global_fixture_first_module.php" />
209+
<magentoConfigFixture scopeType="store" scopeCode="current" path="test_section/test_group/field_4" value="4th field globally overridden value"/>
210+
<magentoConfigFixture scopeType="store" scopeCode="current" path="test_section/test_group/field_5" newValue="5th field globally replaced value"/>
211+
</global>
207212
</overrides>

dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ public static function getInstance(): ConfigInterface
5454
return self::$instance;
5555
}
5656

57+
/**
58+
* Get config from global node
59+
*
60+
* @param string|null $fixtureType
61+
* @return array
62+
*/
63+
public function getGlobalConfig(?string $fixtureType = null): array
64+
{
65+
$result = $this->config['global'] ?? [];
66+
if ($fixtureType) {
67+
$result = $result[$fixtureType] ?? [];
68+
}
69+
70+
return $result;
71+
}
72+
5773
/**
5874
* Self instance setter.
5975
*

dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Config/Converter.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Converter implements ConverterInterface
3434
public function convert($source)
3535
{
3636
$this->xpath = new \DOMXPath($source);
37-
$config = [];
37+
$config = $this->getGlobalConfig($this->xpath);
3838
foreach ($this->xpath->query('//test') as $testOverride) {
3939
$className = ltrim($testOverride->getAttribute('class'), '\\');
4040
$config[$className] = $this->getTestConfigByFixtureType($testOverride);
@@ -182,4 +182,36 @@ protected function fillAdminConfigFixtureAttributes(\DOMElement $fixture): array
182182
'remove' => $fixture->getAttribute('remove'),
183183
];
184184
}
185+
/**
186+
* Get global configurations
187+
*
188+
* @param \DOMXPath $xpath
189+
* @return array
190+
*/
191+
private function getGlobalConfig(\DOMXPath $xpath): array
192+
{
193+
foreach ($xpath->query('//global') as $globalOverride) {
194+
$config = $this->fillGlobalConfigByFixtureType($globalOverride);
195+
}
196+
197+
return $config ?? [];
198+
}
199+
200+
/**
201+
* Fill global configurations node
202+
*
203+
* @param \DOMElement $node
204+
* @return array
205+
*/
206+
private function fillGlobalConfigByFixtureType(\DOMElement $node): array
207+
{
208+
$config = [];
209+
foreach (self::FIXTURE_TYPES as $fixtureType) {
210+
foreach ($node->getElementsByTagName($fixtureType) as $fixture) {
211+
$config['global'][$fixtureType][] = $this->fillAttributes($fixture);
212+
}
213+
}
214+
215+
return $config;
216+
}
185217
}

dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Fixture/Applier/Base.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
abstract class Base implements ApplierInterface
1414
{
15+
/** @var array */
16+
private $globalConfig;
17+
1518
/** @var array */
1619
private $classConfig;
1720

@@ -21,6 +24,27 @@ abstract class Base implements ApplierInterface
2124
/** @var array */
2225
private $dataSetConfig;
2326

27+
/**
28+
* Get global node config
29+
*
30+
* @return array
31+
*/
32+
public function getGlobalConfig(): array
33+
{
34+
return $this->globalConfig;
35+
}
36+
37+
/**
38+
* Set global node config
39+
*
40+
* @param array $globalConfig
41+
* @return void
42+
*/
43+
public function setGlobalConfig(array $globalConfig): void
44+
{
45+
$this->globalConfig = $globalConfig;
46+
}
47+
2448
/**
2549
* Get class node config
2650
*
@@ -92,6 +116,7 @@ public function setDataSetConfig(array $dataSetConfig): void
92116
protected function getPrioritizedConfig(): array
93117
{
94118
return [
119+
$this->getGlobalConfig(),
95120
$this->getClassConfig(),
96121
$this->getMethodConfig(),
97122
$this->getDataSetConfig(),

dev/tests/integration/framework/Magento/TestFramework/Workaround/Override/Fixture/Resolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ private function getApplier(TestCase $test, string $fixtureType): ApplierInterfa
195195
}
196196
/** @var Base $applier */
197197
$applier = $this->appliersList[$fixtureType];
198+
$applier->setGlobalConfig($this->config->getGlobalConfig($fixtureType));
198199
$applier->setClassConfig($this->config->getClassConfig($test, $fixtureType));
199200
$applier->setMethodConfig($this->config->getMethodConfig($test, $fixtureType));
200201
$applier->setDataSetConfig(

dev/tests/integration/framework/Magento/TestFramework/Workaround/etc/overrides.xsd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<xs:complexType>
1111
<xs:sequence minOccurs="0" maxOccurs="unbounded">
1212
<xs:element name="test" type="test" minOccurs="0" maxOccurs="unbounded" />
13+
<xs:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
1314
</xs:sequence>
1415
</xs:complexType>
1516
</xs:element>
@@ -77,4 +78,12 @@
7778
<xs:attribute name="newValue" type="xs:string"/>
7879
<xs:attribute name="remove" type="xs:boolean"/>
7980
</xs:complexType>
81+
<xs:complexType name="global">
82+
<xs:sequence minOccurs="0" maxOccurs="unbounded">
83+
<xs:element name="magentoDataFixture" type="dataFixture" minOccurs="0" maxOccurs="unbounded" />
84+
<xs:element name="magentoDataFixtureBeforeTransaction" type="dataFixture" minOccurs="0" maxOccurs="unbounded" />
85+
<xs:element name="magentoConfigFixture" type="configFixture" minOccurs="0" maxOccurs="unbounded" />
86+
<xs:element name="magentoAdminConfigFixture" type="adminConfigFixture" minOccurs="0" maxOccurs="unbounded" />
87+
</xs:sequence>
88+
</xs:complexType>
8089
</xs:schema>

dev/tests/integration/testsuite/Magento/AsynchronousOperations/Model/MassScheduleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
/**
2828
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
29+
*
30+
* @magentoDbIsolation disabled
2931
*/
3032
class MassScheduleTest extends \PHPUnit\Framework\TestCase
3133
{
@@ -64,6 +66,9 @@ class MassScheduleTest extends \PHPUnit\Framework\TestCase
6466
*/
6567
private $skus = [];
6668

69+
/** @var string */
70+
private $logFilePath;
71+
6772
/**
6873
* @var Registry
6974
*/

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/RelationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* Test relation customization
18+
*
19+
* @magentoDbIsolation disabled
1820
*/
1921
class RelationTest extends \Magento\TestFramework\Indexer\TestCase
2022
{

0 commit comments

Comments
 (0)