Skip to content

Commit

Permalink
Merge pull request #55 from magento-commerce/imported-fredden-magento…
Browse files Browse the repository at this point in the history
…-semver-72

[Imported] Detect when virtualTypes move elsewhere
  • Loading branch information
sidolov committed Mar 7, 2024
2 parents d7feca7 + 962967d commit de42815
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dev/tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public function changesDataProvider()
],
''
],
'moved-to-app-etc' => [
$pathToFixtures . '/moved-to-app-etc/source-code-before',
$pathToFixtures . '/moved-to-app-etc/source-code-after',
[
'#Suggested semantic versioning change: NONE#',
],
'Patch change is detected.',
],
'moved-to-another-module' => [
$pathToFixtures . '/moved-to-another-module/source-code-before',
$pathToFixtures . '/moved-to-another-module/source-code-after',
[
'#Suggested semantic versioning change: NONE#',
],
'Patch change is detected.',
],
'moved-to-global' => [
$pathToFixtures . '/moved-to-global/source-code-before',
$pathToFixtures . '/moved-to-global/source-code-after',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in Magento_AnotherTestModule's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in Magento_TestModule's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in a the global app/etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- This file is in a module's etc/ directory -->

<!-- @api -->
<virtualType name="customCacheInstance" type="Magento\Framework\App\Cache" shared="true"/>
<!-- @api -->
<virtualType name="customCacheInstance2" type="Magento\Test" />
<!-- @api -->
<virtualType name="customCacheInstance3" type="Magento\Framework\Test2" shared="false"/>
</config>
11 changes: 11 additions & 0 deletions src/Analyzer/DiXml/VirtualTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ public function analyze($registryBefore, $registryAfter)
continue;
}

foreach ($nodesAfter as $newModuleNodes) {
foreach ($newModuleNodes as $nodeAfter) {
if ($nodeBefore->getName() !== $nodeAfter->getName()) {
continue;
}

$this->triggerNodeChange($nodeBefore, $nodeAfter, $fileBefore);
continue 3;
}
}

$operation = new VirtualTypeRemoved($fileBefore, $name);
$this->report->add('di', $operation);
}
Expand Down
1 change: 1 addition & 0 deletions src/resources/application_includes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
app/code
app/etc
lib/internal/Magento
Inventory*
Adobe*

0 comments on commit de42815

Please sign in to comment.