Skip to content

Commit ad03c33

Browse files
committed
MC-38349: Create automated test for SVC changes
- Completed expanding di_xml and layout cases - Began expanding MFTF
1 parent 2acead8 commit ad03c33

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

tests/Unit/Console/Command/CompareSourceCommandDiXmlTest.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command;
99

10-
use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCase;
10+
use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCaseWithRegExp;
1111

1212
/**
1313
* Test semantic version checker CLI command dealing with di.xml
1414
*/
15-
class CompareSourceCommandDiXmlTest extends AbstractTestCase
15+
class CompareSourceCommandDiXmlTest extends AbstractTestCaseWithRegExp
1616
{
1717
/**
1818
* Test semantic version checker CLI command for changes of the database schema.
@@ -21,7 +21,7 @@ class CompareSourceCommandDiXmlTest extends AbstractTestCase
2121
* @param string $pathToSourceCodeAfter
2222
* @param string[] $expectedLogEntries
2323
* @param string $expectedOutput
24-
* @param string[] $unexpectedLogEntries
24+
* @param bool $shouldSkipTest
2525
* @return void
2626
* @throws \Exception
2727
* @dataProvider changesDataProvider
@@ -31,14 +31,14 @@ public function testExecute(
3131
$pathToSourceCodeAfter,
3232
$expectedLogEntries,
3333
$expectedOutput,
34-
$unexpectedLogEntries = []
34+
$shouldSkipTest = false
3535
) {
3636
$this->doTestExecute(
3737
$pathToSourceCodeBefore,
3838
$pathToSourceCodeAfter,
3939
$expectedLogEntries,
4040
$expectedOutput,
41-
$unexpectedLogEntries
41+
$shouldSkipTest
4242
);
4343
}
4444

@@ -51,47 +51,55 @@ public function changesDataProvider()
5151
$pathToFixtures . '/no-change/source-code-before',
5252
$pathToFixtures . '/no-change/source-code-after',
5353
[
54-
54+
'#Suggested semantic versioning change: NONE#',
5555
],
5656
''
5757
],
5858
'moved-to-global' => [
5959
$pathToFixtures . '/moved-to-global/source-code-before',
6060
$pathToFixtures . '/moved-to-global/source-code-after',
6161
[
62-
'Suggested semantic versioning change: NONE',
62+
'#Suggested semantic versioning change: NONE#',
6363
],
6464
'Patch change is detected.',
6565
],
6666
'moved-to-specific' => [
6767
$pathToFixtures . '/moved-to-specific/source-code-before',
6868
$pathToFixtures . '/moved-to-specific/source-code-after',
6969
[
70-
'Suggested semantic versioning change: MAJOR',
70+
'#Suggested semantic versioning change: MAJOR#',
71+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/di_xml/moved-to-specific/source-code-before/Magento/TestModule/etc/di\.xml:0#',
72+
'#scope\s*\|\s*Virtual Type was changed\s*\|\s*M201#'
7173
],
7274
'Major change is detected.',
7375
],
7476
'remove-type' => [
7577
$pathToFixtures . '/remove-type/source-code-before',
7678
$pathToFixtures . '/remove-type/source-code-after',
7779
[
78-
'Suggested semantic versioning change: MAJOR',
80+
'#Suggested semantic versioning change: MAJOR#',
81+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/di_xml/remove-type/source-code-before/Magento/TestModule/etc/di\.xml:0#',
82+
'#customCacheInstance2\s*\|\s*Virtual Type was removed\s*\|\s*M200\s*#'
7983
],
8084
'Major change is detected.',
8185
],
8286
'change-type' => [
8387
$pathToFixtures . '/change-type/source-code-before',
8488
$pathToFixtures . '/change-type/source-code-after',
8589
[
86-
'Suggested semantic versioning change: MAJOR',
90+
'#Suggested semantic versioning change: MAJOR#',
91+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/di_xml/change-type/source-code-before/Magento/TestModule/etc/di\.xml:0#',
92+
'#type\s*\|\s*Virtual Type was changed\s*\|\s*M201#'
8793
],
8894
'Major change is detected.',
8995
],
9096
'change-name' => [
91-
$pathToFixtures . '/change-type/source-code-before',
92-
$pathToFixtures . '/change-type/source-code-after',
97+
$pathToFixtures . '/change-name/source-code-before',
98+
$pathToFixtures . '/change-name/source-code-after',
9399
[
94-
'Suggested semantic versioning change: MAJOR',
100+
'#Suggested semantic versioning change: MAJOR#',
101+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/di_xml/change-name/source-code-before/Magento/TestModule/etc/di\.xml:0#',
102+
'#cacheInstance\s*\|\s*Virtual Type was removed\s*\|\s*M200#'
95103
],
96104
'Major change is detected.',
97105
],

tests/Unit/Console/Command/CompareSourceCommandLayoutTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command;
99

10-
use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCase;
10+
use Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest\AbstractTestCaseWithRegExp;
1111

1212
/**
1313
* Test semantic version checker CLI command dealing with layout xml.
1414
*/
15-
class CompareSourceCommandLayoutTest extends AbstractTestCase
15+
class CompareSourceCommandLayoutTest extends AbstractTestCaseWithRegExp
1616
{
1717
/**
1818
* Test semantic version checker CLI command for changes of the database schema.
@@ -21,7 +21,7 @@ class CompareSourceCommandLayoutTest extends AbstractTestCase
2121
* @param string $pathToSourceCodeAfter
2222
* @param string[] $expectedLogEntries
2323
* @param string $expectedOutput
24-
* @param string[] $unexpectedLogEntries
24+
* @param bool $shouldSkipTest
2525
* @return void
2626
* @throws \Exception
2727
* @dataProvider changesDataProvider
@@ -31,14 +31,14 @@ public function testExecute(
3131
$pathToSourceCodeAfter,
3232
$expectedLogEntries,
3333
$expectedOutput,
34-
$unexpectedLogEntries = []
34+
$shouldSkipTest = false
3535
) {
3636
$this->doTestExecute(
3737
$pathToSourceCodeBefore,
3838
$pathToSourceCodeAfter,
3939
$expectedLogEntries,
4040
$expectedOutput,
41-
$unexpectedLogEntries
41+
$shouldSkipTest
4242
);
4343
}
4444

@@ -51,23 +51,29 @@ public function changesDataProvider()
5151
$pathToFixtures . '/block_remove/source-code-before',
5252
$pathToFixtures . '/block_remove/source-code-after',
5353
[
54-
'Suggested semantic versioning change: MAJOR',
54+
'#Suggested semantic versioning change: MAJOR#',
55+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/layout_xml/block_remove/source-code-before/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist\.xml:0#',
56+
'#admin\.customer\.view\.wishlist\s*\|\s*Block was removed\s*\|\s*M220#'
5557
],
5658
'Major change is detected.',
5759
],
5860
'container_remove' => [
5961
$pathToFixtures . '/container_remove/source-code-before',
6062
$pathToFixtures . '/container_remove/source-code-after',
6163
[
62-
'Suggested semantic versioning change: MAJOR',
64+
'#Suggested semantic versioning change: MAJOR#',
65+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/layout_xml/container_remove/source-code-before/Magento/Customer/view/adminhtml/layout/customer_index_viewwishlist\.xml:0#',
66+
'#root\s*\|\s*Container was removed\s*\|\s*M221#'
6367
],
6468
'Major change is detected.',
6569
],
6670
'update_remove' => [
6771
$pathToFixtures . '/update_remove/source-code-before',
6872
$pathToFixtures . '/update_remove/source-code-after',
6973
[
70-
'Suggested semantic versioning change: MAJOR',
74+
'#Suggested semantic versioning change: MAJOR#',
75+
'#MAJOR\s*\|\s*Console/Command/CompareSourceCommandTest/_files/layout_xml/update_remove/source-code-before/Magento/ConfigurableProduct/view/adminhtml/layout/catalog_product_configurable\.xml:0',
76+
'#catalog_product_superconfig_config\s*\|\s*An Update was removed\s*\|\s*M222'
7177
],
7278
'Major change is detected.',
7379
],

tests/Unit/Console/Command/CompareSourceCommandMftfTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function changesDataProvider()
8989
$pathToFixtures . '/actionGroup-removed/source-code-after',
9090
[
9191
'Mftf (MAJOR)',
92+
'CompareSourceCommandTest/_files/mftf/actionGroup-removed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
9293
'ActionGroup/ActionGroup1 | <actionGroup> was removed | M200'
9394
],
9495
'Major change is detected.'
@@ -98,6 +99,7 @@ public function changesDataProvider()
9899
$pathToFixtures . '/actionGroup-added/source-code-after',
99100
[
100101
'Mftf (MINOR)',
102+
'CompareSourceCommandTest/_files/mftf/actionGroup-added/source-code-after/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
101103
'ActionGroup/ActionGroup2 | <actionGroup> was added | M225'
102104
],
103105
'Minor change is detected.'
@@ -107,6 +109,7 @@ public function changesDataProvider()
107109
$pathToFixtures . '/new-module-actionGroup-added/source-code-after',
108110
[
109111
'Mftf (MINOR)',
112+
'CompareSourceCommandTest/_files/mftf/new-module-actionGroup-added/source-code-after/Magento/TestModuleTwo/Test/Mftf/ActionGroup/actionGroup.xml:0',
110113
'ActionGroup/ActionGroup2 | <actionGroup> was added | M225'
111114
],
112115
'Minor change is detected.'
@@ -116,6 +119,7 @@ public function changesDataProvider()
116119
$pathToFixtures . '/actionGroup-argument-changed/source-code-after',
117120
[
118121
'Mftf (MAJOR)',
122+
'actionGroup-argument-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
119123
'ActionGroup/ActionGroup1/arg1/type | <actionGroup> <argument> was changed | M203'
120124
],
121125
'Major change is detected.'
@@ -125,6 +129,7 @@ public function changesDataProvider()
125129
$pathToFixtures . '/actionGroup-argument-removed/source-code-after',
126130
[
127131
'Mftf (MAJOR)',
132+
'CompareSourceCommandTest/_files/mftf/actionGroup-argument-removed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
128133
'ActionGroup/ActionGroup1/Arguments/arg1 | <actionGroup> <argument> was removed | M201'
129134
],
130135
'Major change is detected.'
@@ -134,6 +139,7 @@ public function changesDataProvider()
134139
$pathToFixtures . '/actionGroup-argument-added/source-code-after',
135140
[
136141
'Mftf (MAJOR)',
142+
'CompareSourceCommandTest/_files/mftf/actionGroup-argument-added/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
137143
'ActionGroup/ActionGroup1/arg2 | <actionGroup> <argument> was added | M227'
138144
],
139145
'Major change is detected.'
@@ -143,6 +149,7 @@ public function changesDataProvider()
143149
$pathToFixtures . '/actionGroup-action-changed/source-code-after',
144150
[
145151
'Mftf (PATCH)',
152+
'CompareSourceCommandTest/_files/mftf/actionGroup-action-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
146153
'ActionGroup/ActionGroup1/action1/userInput | <actionGroup> <action> was changed | M204'
147154
],
148155
'Patch change is detected.'
@@ -152,6 +159,7 @@ public function changesDataProvider()
152159
$pathToFixtures . '/actionGroup-action-type-changed/source-code-after',
153160
[
154161
'Mftf (PATCH)',
162+
'CompareSourceCommandTest/_files/mftf/actionGroup-action-type-changed/source-code-before/Magento/TestModule/Test/Mftf/ActionGroup/actionGroup.xml:0',
155163
'ActionGroup/ActionGroup1/action1 | <actionGroup> <action> type was changed | M223'
156164
],
157165
'Patch change is detected.'

0 commit comments

Comments
 (0)