Skip to content

Commit 631cae5

Browse files
Added test for apply_to property
1 parent 250390c commit 631cae5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/com/magento/idea/magento2plugin/actions/generation/generator/EavAttributeSetupPatchGeneratorTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,37 @@ public void testGenerateFileWithGeneratedSourceModel() {
113113

114114
assertGeneratedFileIsCorrect(expectedFile, "src/app/code/Foo/Bar/Setup/Patch/Data", dataPatchFile);
115115
}
116+
117+
public void testGenerateFileWithApplyToAttribute() {
118+
final Project project = myFixture.getProject();
119+
120+
final ProductEntityData productEntityData = new ProductEntityData();
121+
productEntityData.setCode("applied_to_attribute");
122+
productEntityData.setVisibleInGrid(false);
123+
productEntityData.setHtmlAllowedOnFront(false);
124+
productEntityData.setVisibleOnFront(false);
125+
productEntityData.setVisible(true);
126+
productEntityData.setScope(AttributeScope.GLOBAL.getScope());
127+
productEntityData.setLabel("Test Label");
128+
productEntityData.setType("static");
129+
productEntityData.setUsedInGrid(false);
130+
productEntityData.setRequired(false);
131+
productEntityData.setInput("text");
132+
productEntityData.setFilterableInGrid(false);
133+
productEntityData.setSortOrder(10);
134+
productEntityData.setGroup("General");
135+
productEntityData.setApplyTo("configurable,simple");
136+
137+
productEntityData.setDataPatchName("AddAppliedToAttribute");
138+
productEntityData.setModuleName(MODULE_NAME);
139+
140+
final EavAttributeSetupPatchGenerator setupPatchGenerator =
141+
new EavAttributeSetupPatchGenerator(productEntityData, project);
142+
final PsiFile dataPatchFile = setupPatchGenerator.generate("testGenerateFileWithApplyToAttribute");
143+
144+
final String filePatch = this.getFixturePath("AddAppliedToAttribute.php");
145+
final PsiFile expectedFile = myFixture.configureByFile(filePatch);
146+
147+
assertGeneratedFileIsCorrect(expectedFile, "src/app/code/Foo/Bar/Setup/Patch/Data", dataPatchFile);
148+
}
116149
}

0 commit comments

Comments
 (0)