Skip to content

Commit de42815

Browse files
authored
Merge pull request #55 from magento-commerce/imported-fredden-magento-semver-72
[Imported] Detect when virtualTypes move elsewhere
2 parents d7feca7 + 962967d commit de42815

File tree

7 files changed

+96
-0
lines changed

7 files changed

+96
-0
lines changed

dev/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@ public function changesDataProvider()
5555
],
5656
''
5757
],
58+
'moved-to-app-etc' => [
59+
$pathToFixtures . '/moved-to-app-etc/source-code-before',
60+
$pathToFixtures . '/moved-to-app-etc/source-code-after',
61+
[
62+
'#Suggested semantic versioning change: NONE#',
63+
],
64+
'Patch change is detected.',
65+
],
66+
'moved-to-another-module' => [
67+
$pathToFixtures . '/moved-to-another-module/source-code-before',
68+
$pathToFixtures . '/moved-to-another-module/source-code-after',
69+
[
70+
'#Suggested semantic versioning change: NONE#',
71+
],
72+
'Patch change is detected.',
73+
],
5874
'moved-to-global' => [
5975
$pathToFixtures . '/moved-to-global/source-code-before',
6076
$pathToFixtures . '/moved-to-global/source-code-after',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<!-- This file is in Magento_AnotherTestModule's etc/ directory -->
10+
11+
<!-- @api -->
12+
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
13+
<!-- @api -->
14+
<virtualType name="customCacheInstance2" type="Magento\Test" />
15+
<!-- @api -->
16+
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
17+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<!-- This file is in Magento_TestModule's etc/ directory -->
10+
11+
<!-- @api -->
12+
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
13+
<!-- @api -->
14+
<virtualType name="customCacheInstance2" type="Magento\Test" />
15+
<!-- @api -->
16+
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
17+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<!-- This file is in a the global app/etc/ directory -->
10+
11+
<!-- @api -->
12+
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
13+
<!-- @api -->
14+
<virtualType name="customCacheInstance2" type="Magento\Test" />
15+
<!-- @api -->
16+
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
17+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<!-- This file is in a module's etc/ directory -->
10+
11+
<!-- @api -->
12+
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
13+
<!-- @api -->
14+
<virtualType name="customCacheInstance2" type="Magento\Test" />
15+
<!-- @api -->
16+
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
17+
</config>

src/Analyzer/DiXml/VirtualTypeAnalyzer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ public function analyze($registryBefore, $registryAfter)
6767
continue;
6868
}
6969

70+
foreach ($nodesAfter as $newModuleNodes) {
71+
foreach ($newModuleNodes as $nodeAfter) {
72+
if ($nodeBefore->getName() !== $nodeAfter->getName()) {
73+
continue;
74+
}
75+
76+
$this->triggerNodeChange($nodeBefore, $nodeAfter, $fileBefore);
77+
continue 3;
78+
}
79+
}
80+
7081
$operation = new VirtualTypeRemoved($fileBefore, $name);
7182
$this->report->add('di', $operation);
7283
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
app/code
2+
app/etc
23
lib/internal/Magento
34
Inventory*
45
Adobe*

0 commit comments

Comments
 (0)