Skip to content

Commit eb3866b

Browse files
committed
MQE-2247: Implement additional <section> and <operation> entity use cases in SVC tool
added <section> entity use cases
1 parent 178b3c6 commit eb3866b

File tree

11 files changed

+206
-5
lines changed

11 files changed

+206
-5
lines changed

src/Analyzer/Mftf/SectionAnalyzer.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionAdded;
1111
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementAdded;
1212
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementChanged;
13+
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementParameterizedChanged;
1314
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementRemoved;
15+
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementSelectorChanged;
16+
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionElementTypeChanged;
1417
use Magento\SemanticVersionChecker\Operation\Mftf\Section\SectionRemoved;
1518
use Magento\SemanticVersionChecker\Scanner\MftfScanner;
1619
use PHPSemVerChecker\Registry\Registry;
@@ -22,6 +25,18 @@ class SectionAnalyzer extends AbstractEntityAnalyzer
2225
const MFTF_DATA_TYPE = 'section';
2326
const MFTF_DATA_DIRECTORY = '/Mftf/Section/';
2427

28+
/**
29+
* operations array
30+
*
31+
* @var string[]
32+
*/
33+
private static $operations = [
34+
AbstractEntityAnalyzer::DEFAULT_OPERATION_KEY => SectionElementChanged::class,
35+
'selector' => SectionElementSelectorChanged::class,
36+
'type' => SectionElementTypeChanged::class,
37+
'parameterized' => SectionElementParameterizedChanged::class
38+
];
39+
2540
/**
2641
* MFTF section.xml analyzer
2742
*
@@ -91,7 +106,7 @@ public function analyze(Registry $registryBefore, Registry $registryAfter)
91106
$matchingElement['attributes'],
92107
$this->getReport(),
93108
$filenames,
94-
[AbstractEntityAnalyzer::DEFAULT_OPERATION_KEY => SectionElementChanged::class],
109+
self::$operations,
95110
"$operationTarget/$beforeFieldKey"
96111
);
97112
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Magento\SemanticVersionChecker\Operation\Mftf\Section;
4+
5+
use Magento\SemanticVersionChecker\Operation\Mftf\MftfOperation;
6+
use PHPSemVerChecker\SemanticVersioning\Level;
7+
8+
/**
9+
* Section <element> parameterized attribute was modified
10+
*/
11+
class SectionElementParameterizedChanged extends MftfOperation
12+
{
13+
/**
14+
* Error codes.
15+
*
16+
* @var array
17+
*/
18+
protected $code = 'M250';
19+
20+
/**
21+
* Operation Severity
22+
* @var int
23+
*/
24+
protected $level = Level::MAJOR;
25+
26+
/**
27+
* Operation message.
28+
*
29+
* @var string
30+
*/
31+
protected $reason = '<section> <element> parameterized was changed';
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Magento\SemanticVersionChecker\Operation\Mftf\Section;
4+
5+
use Magento\SemanticVersionChecker\Operation\Mftf\MftfOperation;
6+
use PHPSemVerChecker\SemanticVersioning\Level;
7+
8+
/**
9+
* Section <element> selector was modified
10+
*/
11+
class SectionElementSelectorChanged extends MftfOperation
12+
{
13+
/**
14+
* Error codes.
15+
*
16+
* @var array
17+
*/
18+
protected $code = 'M219';
19+
20+
/**
21+
* Operation Severity
22+
* @var int
23+
*/
24+
protected $level = Level::PATCH;
25+
26+
/**
27+
* Operation message.
28+
*
29+
* @var string
30+
*/
31+
protected $reason = '<section> <element> selector was changed';
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Magento\SemanticVersionChecker\Operation\Mftf\Section;
4+
5+
use Magento\SemanticVersionChecker\Operation\Mftf\MftfOperation;
6+
use PHPSemVerChecker\SemanticVersioning\Level;
7+
8+
/**
9+
* Section <element> type was modified
10+
*/
11+
class SectionElementTypeChanged extends MftfOperation
12+
{
13+
/**
14+
* Error codes.
15+
*
16+
* @var array
17+
*/
18+
protected $code = 'M218';
19+
20+
/**
21+
* Operation Severity
22+
* @var int
23+
*/
24+
protected $level = Level::PATCH;
25+
26+
/**
27+
* Operation message.
28+
*
29+
* @var string
30+
*/
31+
protected $reason = '<section> <element> type was changed';
32+
}

tests/Unit/Console/Command/CompareSourceCommandMftfTest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,33 @@ public function changesDataProvider()
361361
],
362362
'Major change is detected.'
363363
],
364-
'section-element-changed' => [
365-
$pathToFixtures . '/section-element-changed/source-code-before',
366-
$pathToFixtures . '/section-element-changed/source-code-after',
364+
'section-element-selector-changed' => [
365+
$pathToFixtures . '/section-element-selector-changed/source-code-before',
366+
$pathToFixtures . '/section-element-selector-changed/source-code-after',
367367
[
368368
'Mftf (PATCH)',
369-
'Section/SampleSection/element1/selector | <section> <element> was changed | M217'
369+
'Section/SampleSection/element1/selector | <section> <element> selector was changed | M219'
370370
],
371371
'Patch change is detected.'
372372
],
373+
'section-element-type-changed' => [
374+
$pathToFixtures . '/section-element-type-changed/source-code-before',
375+
$pathToFixtures . '/section-element-type-changed/source-code-after',
376+
[
377+
'Mftf (PATCH)',
378+
'Section/SampleSection/element1/type | <section> <element> type was changed | M218'
379+
],
380+
'Patch change is detected.'
381+
],
382+
'section-element-parameterized-changed' => [
383+
$pathToFixtures . '/section-element-parameterized-changed/source-code-before',
384+
$pathToFixtures . '/section-element-parameterized-changed/source-code-after',
385+
[
386+
'Mftf (MAJOR)',
387+
'Section/SampleSection/element1/parameterized | <section> <element> parameterized was changed | M250'
388+
],
389+
'Major change is detected.'
390+
],
373391
'section-element-added' => [
374392
$pathToFixtures . '/section-element-added/source-code-before',
375393
$pathToFixtures . '/section-element-added/source-code-after',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="SampleSection">
10+
<element name="element1" type="block" selector="span:nth-of-type({{var}})"/>
11+
</section>
12+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="SampleSection">
10+
<element name="element1" type="block" selector="span:nth-of-type({{var}})" parameterized="true"/>
11+
</section>
12+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="SampleSection">
10+
<element name="element1" type="block" selector="#newSelector"/>
11+
</section>
12+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="SampleSection">
10+
<element name="element1" type="block" selector="#element1"/>
11+
</section>
12+
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
9+
<section name="SampleSection">
10+
<element name="element1" type="input" selector="#element1"/>
11+
</section>
12+
</sections>

0 commit comments

Comments
 (0)