Skip to content

Commit 1336187

Browse files
committed
Added graphql linemarker test
1 parent 09b3683 commit 1336187

File tree

6 files changed

+44
-14
lines changed

6 files changed

+44
-14
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+
}

tests/com/magento/idea/magento2plugin/linemarker/php/LinemarkerPhpFixtureTestCase.java renamed to tests/com/magento/idea/magento2plugin/linemarker/LinemarkerFixtureTestCase.java

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

77
import com.intellij.codeInsight.daemon.LineMarkerInfo;
88
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
@@ -12,19 +12,18 @@
1212
import com.magento.idea.magento2plugin.magento.packages.File;
1313
import java.util.List;
1414

15-
abstract public class LinemarkerPhpFixtureTestCase extends BaseProjectTestCase {
15+
abstract public class LinemarkerFixtureTestCase extends BaseProjectTestCase {
1616

1717
private static final String testDataFolderPath = "testData" + File.separator + "linemarker" + File.separator;
18-
private static final String fixturesFolderPath = "php" + File.separator;
1918

2019
@Override
2120
protected void setUp() throws Exception {
2221
super.setUp();
2322
myFixture.setTestDataPath(testDataFolderPath);
2423
}
2524

26-
protected String getFixturePath(String fileName) {
27-
return prepareFixturePath(fileName, fixturesFolderPath);
25+
protected String getFixturePath(String fileName, String folder) {
26+
return prepareFixturePath(fileName, folder + File.separator);
2827
}
2928

3029
protected void assertHasLinemarkerWithTooltipAndIcon(String tooltip, String icon) {
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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
*/
55
package com.magento.idea.magento2plugin.linemarker.php;
66

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

911
public void testTypeNameClassShouldHaveLinemarker() {
10-
String filePath = this.getFixturePath("Topmenu.php");
12+
String filePath = this.getFixturePath("Topmenu.php", "php");
1113
myFixture.configureByFile(filePath);
1214

1315
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1416
}
1517

1618
public void testRegularPhpClassShouldNotHaveLinemarker() {
17-
String filePath = this.getFixturePath("ClassNotConfiguredInDiXml.php");
19+
String filePath = this.getFixturePath("ClassNotConfiguredInDiXml.php", "php");
1820
myFixture.configureByFile(filePath);
1921

2022
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
*/
55
package com.magento.idea.magento2plugin.linemarker.php;
66

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

911
public void testObserverClassShouldHaveLinemarker() {
10-
String filePath = this.getFixturePath("TestObserver.php");
12+
String filePath = this.getFixturePath("TestObserver.php", "php");
1113
myFixture.configureByFile(filePath);
1214

1315
assertHasLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");
1416
}
1517

1618
public void testRegularPhpClassShouldNotHaveLinemarker() {
17-
String filePath = this.getFixturePath("TestNotObserver.php");
19+
String filePath = this.getFixturePath("TestNotObserver.php", "php");
1820
myFixture.configureByFile(filePath);
1921

2022
assertHasNoLinemarkerWithTooltipAndIcon("Navigate to configuration", "/fileTypes/xml.svg");

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
88
import com.magento.idea.magento2plugin.MagentoIcons;
9+
import com.magento.idea.magento2plugin.linemarker.LinemarkerFixtureTestCase;
910

10-
public class WebApiLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
11+
public class WebApiLinemarkerRegistrarTest extends LinemarkerFixtureTestCase {
1112

1213
private static final String expectedClassLineMarkerTooltip =
1314
"Navigate to Web API configuration:<pre> PUT /V1/blog/post\n" +
@@ -26,7 +27,7 @@ public class WebApiLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase
2627
* Class configured as WEB API service in web_api.xml should have WEB API line markers
2728
*/
2829
public void testWebApiServiceShouldHaveLinemarker() {
29-
String filePath = this.getFixturePath("TestService.php");
30+
String filePath = this.getFixturePath("TestService.php", "php");
3031

3132
//work around for issue caused by com.magento.idea.magento2plugin.linemarker.xml.LineMarkerXmlTagDecorator
3233
//in com.intellij.psi.impl.smartPointers.SmartPsiElementPointerImpl.createElementInfo
@@ -50,7 +51,7 @@ public void testWebApiServiceShouldHaveLinemarker() {
5051
* Regular class should not have WEB API line markers
5152
*/
5253
public void testRegularPhpClassShouldNotHaveLinemarker() {
53-
String filePath = this.getFixturePath("ClassNotConfiguredInWebApiXml.php");
54+
String filePath = this.getFixturePath("ClassNotConfiguredInWebApiXml.php", "php");
5455
myFixture.configureByFile(filePath);
5556

5657
//assert class line marker

0 commit comments

Comments
 (0)