Skip to content

Commit 23780a2

Browse files
author
Vitaliy
authored
Merge pull request #242 from magento/cover-reference-container-by-tests
Covered referenceContainer related functionality by tests
2 parents 2f254fc + 0a5163a commit 23780a2

File tree

6 files changed

+73
-4
lines changed

6 files changed

+73
-4
lines changed

gradle-tasks/pmd/ruleset.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
<description>
1414
Magento PhpStorm rules
1515
</description>
16-
<rule ref="category/java/bestpractices.xml" />
17-
<rule ref="category/java/codestyle.xml"/>
16+
<rule ref="category/java/bestpractices.xml">
17+
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
18+
</rule>
19+
<rule ref="category/java/codestyle.xml">
20+
<exclude name="AtLeastOneConstructor" />
21+
</rule>
1822
<rule ref="category/java/design.xml">
1923
<exclude name="LawOfDemeter"/>
2024
</rule>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
3+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
4+
<body>
5+
<referenceContainer name="test_index_index<caret>"/>
6+
</body>
7+
</page>

testData/project/magento2/vendor/magento/module-catalog/view/frontend/layout/test_index_index.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
44
<body>
5-
<referenceContainer name="after.body.start">
5+
<container name="test_index_index_container">
66
<block name="test_index_index_block" />
7+
</container>
8+
<container name="test_index_index_container2">
79
<block name="test_index_index_block2" />
8-
</referenceContainer>
10+
</container>
911
</body>
1012
</page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
3+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
4+
<body>
5+
<referenceContainer name="test_index_index_container2<caret>">
6+
</referenceContainer>
7+
</body>
8+
</page>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.completion.xml;
7+
8+
import com.magento.idea.magento2plugin.magento.files.LayoutXml;
9+
10+
public class LayoutContainerCompletionRegistrarTest extends CompletionXmlFixtureTestCase {
11+
12+
/**
13+
* The `name` attribute of the `referenceContainer` tag in layout XML must
14+
* have completion based on `name` attribute of `container` tags.
15+
*/
16+
public void testReferenceContainerMustHaveCompletion() {
17+
final String filePath = this.getFixturePath(LayoutXml.DEFAULT_FILENAME);
18+
myFixture.configureByFile(filePath);
19+
20+
assertCompletionContains(
21+
filePath,
22+
"test_index_index_container",
23+
"test_index_index_container2"
24+
);
25+
}
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.reference.xml;
7+
8+
import com.magento.idea.magento2plugin.magento.files.LayoutXml;
9+
10+
public class LayoutContainerReferenceRegistrarTest extends ReferenceXmlFixtureTestCase {
11+
12+
/**
13+
* The `name` attribute of the `referenceContainer` tag in layout XML must
14+
* have reference to the `name` attribute of `container` tag.
15+
*/
16+
public void testReferenceContainerMustHaveReference() {
17+
final String filePath = this.getFixturePath(LayoutXml.DEFAULT_FILENAME);
18+
myFixture.configureByFile(filePath);
19+
20+
assertHasReferenceToXmlTag("container");
21+
}
22+
}

0 commit comments

Comments
 (0)