Skip to content

Commit db49b23

Browse files
author
Vitaliy
authored
Merge pull request #127 from vasilii-b/test-coverage-php-class-completion-for-backend_model
[bugfix] [Tests] Test coverage for PHP class completion for backend model; bugfix for #126
2 parents bf76b18 + 482871d commit db49b23

File tree

19 files changed

+425
-27
lines changed

19 files changed

+425
-27
lines changed

src/com/magento/idea/magento2plugin/completion/xml/XmlCompletionContributor.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,19 @@ public XmlCompletionContributor() {
118118
new PhpClassCompletionProvider()
119119
);
120120

121-
// <backend_model>completion</backend_model>
122-
extend(CompletionType.BASIC,
123-
psiElement(XmlTokenType.XML_DATA_CHARACTERS)
124-
.inside(XmlPatterns.xmlTag().withName(ModuleSystemXml.XML_TAG_BACKEND_MODEL)),
125-
new PhpClassCompletionProvider()
121+
// <backend_model>completion</backend_model> in system.xml
122+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
123+
.inside(XmlPatterns.xmlTag().withName(ModuleSystemXml.XML_TAG_BACKEND_MODEL)
124+
.withParent(XmlPatterns.xmlTag().withName(ModuleSystemXml.FIELD_ELEMENT_NAME))
125+
).inFile(xmlFile().withName(string().matches(ModuleSystemXml.FILE_NAME))),
126+
new PhpClassCompletionProvider()
126127
);
127128

128-
// <randomTag backend_model="completion">
129+
// <randomTag backend_model="completion"> in config.xml
129130
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
130-
.inside(XmlPatterns.xmlAttribute().withName(ModuleConfigXml.XML_ATTRIBUTE_BACKEND_MODEL)),
131-
new PhpClassCompletionProvider()
131+
.inside(XmlPatterns.xmlAttribute().withName(ModuleConfigXml.XML_ATTRIBUTE_BACKEND_MODEL))
132+
.inFile(xmlFile().withName(string().matches(ModuleConfigXml.FILE_NAME))),
133+
new PhpClassCompletionProvider()
132134
);
133135

134136
// <parameter source_model="completion">...</parameter> in widget.xml files.

src/com/magento/idea/magento2plugin/magento/files/ModuleConfigXml.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
package com.magento.idea.magento2plugin.magento.files;
66

77
public class ModuleConfigXml {
8+
public static final String FILE_NAME = "config.xml";
89
public static final String XML_ATTRIBUTE_BACKEND_MODEL = "backend_model";
910
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:module:Magento_Store:etc/config.xsd">
9+
<default>
10+
<payment>
11+
<test>
12+
<test backend_model="Yesno<caret>" />
13+
</test>
14+
</payment>
15+
</default>
16+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:module:Magento_Store:etc/config.xsd">
9+
<default>
10+
<payment>
11+
<test>
12+
<test backend_model="Yesno<caret>" />
13+
</test>
14+
</payment>
15+
</default>
16+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:module:Magento_Store:etc/config.xsd">
9+
<default>
10+
<payment>
11+
<test>
12+
<test backend_model="NotExistentClass<caret>" />
13+
</test>
14+
</payment>
15+
</default>
16+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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:module:Magento_Store:etc/config.xsd">
9+
<default>
10+
<payment>
11+
<test>
12+
<test backend_model="Yesno<caret>" />
13+
</test>
14+
</payment>
15+
</default>
16+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
10+
<system>
11+
<section id="catalog">
12+
<group id="test">
13+
<field id="test">
14+
<label>Test suit to check completion WON'T work for backend_model tag</label>
15+
<backend_model>Roles<caret></backend_model>
16+
</field>
17+
</group>
18+
</section>
19+
</system>
20+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
10+
<system>
11+
<section id="catalog">
12+
<group id="test">
13+
<field id="test">
14+
<label>Test suit to check completion for backend_model tag exactly in system.xml file</label>
15+
<backend_model>Roles<caret></backend_model>
16+
</field>
17+
</group>
18+
</section>
19+
</system>
20+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
10+
<system>
11+
<section id="catalog">
12+
<group id="test">
13+
<field id="test">
14+
<label>Test suit to check missing completion for backend_model tag</label>
15+
<backend_model>NotExistingSource<caret></backend_model>
16+
</field>
17+
</group>
18+
</section>
19+
</system>
20+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
10+
<system>
11+
<section id="catalog">
12+
<group id="test">
13+
<field id="test">
14+
<label>Test suit to check completion for backend_model tag</label>
15+
<backend_model>Roles<caret></backend_model>
16+
</field>
17+
</group>
18+
</section>
19+
</system>
20+
</config>

0 commit comments

Comments
 (0)