Skip to content

Commit 5a163a7

Browse files
author
Vitaliy
authored
Merge branch '2.1.0-develop' into cleanup-01
2 parents 7efc8ec + 22a3dc1 commit 5a163a7

File tree

11 files changed

+238
-115
lines changed

11 files changed

+238
-115
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright © Magento, Inc. All rights reserved.
2+
# See COPYING.txt for license details.
3+
4+
type Query {
5+
test(input: test!): test @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\ImplementsResolverInterface")
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogGraphQl\Model\Resolver;
8+
9+
class ClassNotConfiguredInSchema
10+
{
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogGraphQl\Model\Resolver;
8+
9+
use Magento\Framework\GraphQl\Query\ResolverInterface;
10+
11+
class ImplementsResolverInterface implements ResolverInterface
12+
{
13+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.linemarker;
7+
8+
import com.intellij.codeInsight.daemon.LineMarkerInfo;
9+
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
10+
import com.magento.idea.magento2plugin.BaseProjectTestCase;
11+
import com.magento.idea.magento2plugin.magento.packages.File;
12+
import java.util.List;
13+
import javax.swing.Icon;
14+
import org.jetbrains.annotations.NotNull;
15+
16+
public abstract class LinemarkerFixtureTestCase extends BaseProjectTestCase {
17+
18+
private static final String TEST_DATA_PATH
19+
= "testData" + File.separator + "linemarker" + File.separator;
20+
21+
@Override
22+
protected void setUp() throws Exception {
23+
super.setUp();
24+
myFixture.setTestDataPath(TEST_DATA_PATH);
25+
}
26+
27+
protected String getFixturePath(final String fileName, final String folder) {
28+
return prepareFixturePath(fileName, folder + File.separator);
29+
}
30+
31+
protected void assertHasLinemarkerWithTooltipAndIcon(final String tooltip, final String icon) {
32+
myFixture.doHighlighting();
33+
34+
final List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
35+
assertNotEmpty(lineMarkers);
36+
for (final LineMarkerInfo lineMarkerInfo: lineMarkers) {
37+
final String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
38+
final Icon lineMarkerIcon = lineMarkerInfo.getIcon();
39+
if (lineMarkerTooltip == null || lineMarkerIcon == null) {
40+
continue;
41+
}
42+
if (lineMarkerTooltip.equals(tooltip)
43+
&& lineMarkerIcon.toString().equals(icon)) {
44+
return;
45+
}
46+
}
47+
48+
final String lineMarkerNotFound
49+
= "Failed that documents contains linemarker with the tooltip `%s`";
50+
fail(String.format(lineMarkerNotFound, tooltip));
51+
}
52+
53+
protected void assertHasNoLinemarkerWithTooltipAndIcon(
54+
final String tooltip,
55+
final String icon
56+
) {
57+
myFixture.doHighlighting();
58+
final String lineMarkerExist
59+
= "Failed that documents not contains linemarker with the tooltip `%s`";
60+
61+
final List<LineMarkerInfo<?>> lineMarkers = getDocumentLineMarkers();
62+
assertNotEmpty(lineMarkers);
63+
for (final LineMarkerInfo lineMarkerInfo: lineMarkers) {
64+
final String lineMarkerTooltip = lineMarkerInfo.getLineMarkerTooltip();
65+
final Icon lineMarkerIcon = lineMarkerInfo.getIcon();
66+
if (lineMarkerTooltip == null || lineMarkerIcon == null) {
67+
continue;
68+
}
69+
if (lineMarkerTooltip.equals(tooltip)
70+
&& lineMarkerIcon.toString().equals(icon)) {
71+
fail(String.format(lineMarkerExist, tooltip));
72+
}
73+
}
74+
}
75+
76+
@NotNull
77+
private List<LineMarkerInfo<?>> getDocumentLineMarkers() {
78+
return DaemonCodeAnalyzerImpl.getLineMarkers(
79+
myFixture.getEditor().getDocument(),
80+
getProject()
81+
);
82+
}
83+
}
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+
6+
package com.magento.idea.magento2plugin.linemarker.graphqls;
7+
8+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
9+
10+
public class GraphQlResolverClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
11+
12+
/**
13+
* Tests linemarkers in the schema.graphqls file for PHP resolver classes.
14+
*/
15+
public void testWithValidSchemaResolver() {
16+
myFixture.configureByFile(this.getFixturePath("schema.graphqls", "graphqls"));
17+
18+
assertHasLinemarkerWithTooltipAndIcon("Navigate to class", "/nodes/class.svg");
19+
}
20+
}

tests/com/magento/idea/magento2plugin/linemarker/php/ConfigurationTypeClassLinemarkerRegistrarTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

7-
public class ConfigurationTypeClassLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
8+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
9+
10+
public class ConfigurationTypeClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
811

12+
/**
13+
* Tests linemarkers in the configured class.
14+
*/
915
public void testTypeNameClassShouldHaveLinemarker() {
10-
String filePath = this.getFixturePath("Topmenu.php");
11-
myFixture.configureByFile(filePath);
16+
myFixture.configureByFile(this.getFixturePath("Topmenu.php", "php"));
1217

1318
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1419
}
1520

21+
/**
22+
* Tests linemarkers in the non-configured class.
23+
*/
1624
public void testRegularPhpClassShouldNotHaveLinemarker() {
17-
String filePath = this.getFixturePath("ClassNotConfiguredInDiXml.php");
18-
myFixture.configureByFile(filePath);
25+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInDiXml.php", "php"));
1926

2027
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
2128
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.linemarker.php;
7+
8+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
9+
10+
public class GraphQlResolverUsageLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
11+
12+
/**
13+
* Tests linemarkers in the resolver class.
14+
*/
15+
public void testResolverClassShouldHaveLinemarker() {
16+
myFixture.configureByFile(this.getFixturePath("Resolver.php", "php"));
17+
18+
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to schema", "/icons/graphqlFile.svg");
19+
}
20+
21+
/**
22+
* Tests linemarkers in the regular class.
23+
*/
24+
public void testRegularClassShouldNotHaveLinemarker() {
25+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInSchema.php", "php"));
26+
27+
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to schema", "/icons/graphqlFile.svg");
28+
}
29+
}

tests/com/magento/idea/magento2plugin/linemarker/php/LinemarkerPhpFixtureTestCase.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

tests/com/magento/idea/magento2plugin/linemarker/php/ObserverClassLinemarkerRegistrarTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.linemarker.php;
67

7-
public class ObserverClassLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
8+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
9+
10+
public class ObserverClassLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
811

12+
/**
13+
* Tests linemarkers in the Observer class.
14+
*/
915
public void testObserverClassShouldHaveLinemarker() {
10-
String filePath = this.getFixturePath("TestObserver.php");
11-
myFixture.configureByFile(filePath);
16+
myFixture.configureByFile(this.getFixturePath("TestObserver.php", "php"));
1217

1318
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1419
}
1520

21+
/**
22+
* Tests linemarkers in the regular class.
23+
*/
1624
public void testRegularPhpClassShouldNotHaveLinemarker() {
17-
String filePath = this.getFixturePath("TestNotObserver.php");
18-
myFixture.configureByFile(filePath);
25+
myFixture.configureByFile(this.getFixturePath("TestNotObserver.php", "php"));
1926

2027
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
2128
}

tests/com/magento/idea/magento2plugin/linemarker/php/PluginTargetLinemarkerRegistrarTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
package com.magento.idea.magento2plugin.linemarker.php;
77

8+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
9+
810
@SuppressWarnings("PMD.JUnitTestContainsTooManyAsserts")
9-
public class PluginTargetLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
11+
public class PluginTargetLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1012

1113
/**
1214
* Tests linemarkers in a class which plugs in to a class and its method.
1315
*/
1416
public void testPluginToClassShouldHaveLinemarker() {
15-
myFixture.configureByFile(this.getFixturePath("Topmenu.php"));
17+
myFixture.configureByFile(this.getFixturePath("Topmenu.php", "php"));
1618

1719
assertHasLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
1820
assertHasLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");
@@ -22,7 +24,7 @@ public void testPluginToClassShouldHaveLinemarker() {
2224
* Tests linemarkers in a class which plugs in to an interface and its method.
2325
*/
2426
public void testPluginToInterfaceShouldHaveLinemarker() {
25-
myFixture.configureByFile(this.getFixturePath("MviewState.php"));
27+
myFixture.configureByFile(this.getFixturePath("MviewState.php", "php"));
2628

2729
assertHasLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
2830
assertHasLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");
@@ -32,7 +34,7 @@ public void testPluginToInterfaceShouldHaveLinemarker() {
3234
* Tests linemarkers in a regular class which does not plug in to any class or interface.
3335
*/
3436
public void testRegularClassShouldNotHaveLinemarker() {
35-
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInDiXml.php"));
37+
myFixture.configureByFile(this.getFixturePath("ClassNotConfiguredInDiXml.php", "php"));
3638

3739
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to target method", "/nodes/method.svg");
3840
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to target class", "/nodes/class.svg");

0 commit comments

Comments
 (0)