Skip to content

Commit eeccce0

Browse files
committed
#305_write unit test for UIComponent completion
1 parent a2257a1 commit eeccce0

File tree

9 files changed

+114
-2
lines changed

9 files changed

+114
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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="after.body.start">
6+
<uiComponent name="test_index_i<caret>"/>
7+
</referenceContainer>
8+
</body>
9+
</page>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
<container name="test_index_index_container2">
99
<block name="test_index_index_block2" />
1010
</container>
11+
<container name="test_index_index_container3">
12+
<uiComponent name="test_index_index" />
13+
</container>
1114
</body>
1215
</page>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<argument name="data" xsi:type="array">
5+
<item name="js_config" xsi:type="array">
6+
<item name="provider" xsi:type="string">widget_recently_compared.recently_compared_datasource</item>
7+
</item>
8+
</argument>
9+
</listing>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<argument name="data" xsi:type="array">
5+
<item name="js_config" xsi:type="array">
6+
<item name="provider" xsi:type="string">widget_recently_viewed.recently_viewed_datasource</item>
7+
</item>
8+
</argument>
9+
<settings>
10+
<deps>
11+
<dep>widget_recently_viewed.recently_viewed_datasource</dep>
12+
</deps>
13+
<spinner>widget_columns</spinner>
14+
</settings>
15+
<dataSource name="recently_viewed_datasource" component="Magento_Catalog/js/product/provider">
16+
<argument name="dataProvider" xsi:type="configurableObject">
17+
<argument name="data" xsi:type="array">
18+
<item name="config" xsi:type="array">
19+
<item name="productStorageConfig" xsi:type="array">
20+
<item name="namespace" xsi:type="string">product_data_storage</item>
21+
<item name="className" xsi:type="string">DataStorage</item>
22+
<item name="updateRequestConfig" xsi:type="array">
23+
<item name="url" xsi:type="serviceUrl" path="/products-render-info"/>
24+
</item>
25+
</item>
26+
<item name="identifiersConfig" xsi:type="array">
27+
<item name="namespace" xsi:type="string">recently_viewed_product</item>
28+
</item>
29+
</item>
30+
</argument>
31+
</argument>
32+
<dataProvider class="\Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider" name="recently_viewed_datasource">
33+
<settings>
34+
<requestFieldName/>
35+
<primaryFieldName/>
36+
</settings>
37+
</dataProvider>
38+
</dataSource>
39+
<columns name="widget_columns" component="Magento_Catalog/js/product/list/listing" template="Magento_Catalog/product/list/listing">
40+
<argument name="data" xsi:type="array">
41+
<item name="config" xsi:type="array">
42+
<item name="label" xsi:type="string" translate="true">Recently Viewed</item>
43+
<item name="additionalClasses" xsi:type="string">widget block-viewed-products-grid</item>
44+
<item name="listTemplate" xsi:type="string">Magento_Catalog/product/list/listing</item>
45+
</item>
46+
</argument>
47+
<settings>
48+
<displayMode>grid</displayMode>
49+
</settings>
50+
<column name="image" component="Magento_Catalog/js/product/list/columns/image" sortOrder="0" displayArea="general-area">
51+
<argument name="data" xsi:type="array">
52+
<item name="config" xsi:type="array">
53+
<item name="imageCode" xsi:type="string">recently_viewed_products_grid_content_widget</item>
54+
</item>
55+
</argument>
56+
<settings>
57+
<label translate="true">Image</label>
58+
<bodyTmpl>Magento_Catalog/product/list/columns/image_with_borders</bodyTmpl>
59+
</settings>
60+
</column>
61+
</columns>
62+
</listing>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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="after.body.start">
6+
<uiComponent name="test_index_i<caret>"/>
7+
</referenceContainer>
8+
</body>
9+
</page>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.completion.xml;
6+
7+
import com.magento.idea.magento2plugin.magento.files.LayoutXml;
8+
9+
public class LayoutUIComponentCompletionRegistrarTest extends CompletionXmlFixtureTestCase {
10+
11+
public void testUIComponentMustHaveCompletion() {
12+
String filePath = this.getFixturePath(LayoutXml.DEFAULT_FILENAME);
13+
myFixture.configureByFile(filePath);
14+
15+
assertCompletionContains(filePath,
16+
"test_index_i",
17+
"test_index_index"
18+
);
19+
}
20+
}

tests/com/magento/idea/magento2plugin/completion/xml/LayoutContainerCompletionRegistrarTest.java renamed to tests/com/magento/idea/magento2plugin/completion/xml/XLayoutContainerCompletionRegistrarTest.java

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

88
import com.magento.idea.magento2plugin.magento.files.LayoutXml;
99

10-
public class LayoutContainerCompletionRegistrarTest extends CompletionXmlFixtureTestCase {
10+
public class XLayoutContainerCompletionRegistrarTest extends CompletionXmlFixtureTestCase {
1111

1212
/**
1313
* The `name` attribute of the `referenceContainer` tag in layout XML must
1414
* have completion based on `name` attribute of `container` tags.
1515
*/
16-
public void testReferenceContainerMustHaveCompletion() {
16+
public void testXReferenceContainerMustHaveCompletion() {
1717
final String filePath = this.getFixturePath(LayoutXml.DEFAULT_FILENAME);
1818
myFixture.configureByFile(filePath);
1919

0 commit comments

Comments
 (0)