File tree Expand file tree Collapse file tree 10 files changed +79
-4
lines changed
src/com/magento/idea/magento2plugin/inspections/graphqls
inspections/graphqls/SchemaResolverInspection
withValidBatchResolverInterface
withValidBatchServiceContractResolverInterface
project/magento2/app/code/Magento/InspectionTest
WithValidBatchResolverInterface
WithValidBatchServiceContractResolverInterface
tests/com/magento/idea/magento2plugin Expand file tree Collapse file tree 10 files changed +79
-4
lines changed Original file line number Diff line number Diff line change 11
11
import com .intellij .lang .jsgraphql .psi .GraphQLValue ;
12
12
import com .intellij .lang .jsgraphql .psi .GraphQLVisitor ;
13
13
import com .jetbrains .php .lang .psi .elements .PhpClass ;
14
+ import com .magento .idea .magento2plugin .bundles .InspectionBundle ;
14
15
import com .magento .idea .magento2plugin .util .GetPhpClassByFQN ;
15
16
import com .magento .idea .magento2plugin .util .magento .graphql .GraphQlUtil ;
16
17
import org .jetbrains .annotations .NotNull ;
17
18
18
19
public class SchemaResolverInspection extends LocalInspectionTool {
19
20
20
- public static final String GraphQlResolverProblemDescription = "Class must implements \\ Magento \\ Framework \\ GraphQl \\ Query \\ ResolverInterface" ;
21
+ private final InspectionBundle inspectionBundle = new InspectionBundle () ;
21
22
22
23
@ NotNull
23
24
@ Override
@@ -38,7 +39,9 @@ public void visitValue(@NotNull GraphQLValue element) {
38
39
}
39
40
if (!GraphQlUtil .isResolver (resolverClass )) {
40
41
holder .registerProblem (element ,
41
- GraphQlResolverProblemDescription ,
42
+ inspectionBundle .message (
43
+ "inspection.graphql.resolver.mustImplement"
44
+ ),
42
45
ProblemHighlightType .ERROR );
43
46
}
44
47
}
Original file line number Diff line number Diff line change
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\\ InspectionTest\\ Model\\ GraphQl\\ WithValidBatchResolverInterface\\ Item" ) @doc (description : " Test" )
6
+ }
Original file line number Diff line number Diff line change
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\\ InspectionTest\\ Model\\ GraphQl\\ WithValidBatchServiceContractResolverInterface\\ Item" ) @doc (description : " Test" )
6
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \InspectionTest \Model \GraphQl \WithValidBatchResolverInterface ;
9
+
10
+ use Magento \Framework \GraphQl \Query \Resolver \BatchResolverInterface ;
11
+
12
+ class Item implements BatchResolverInterface
13
+ {
14
+ }
15
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \InspectionTest \Model \GraphQl \WithValidBatchServiceContractResolverInterface ;
9
+
10
+ use Magento \Framework \GraphQl \Query \Resolver \BatchServiceContractResolverInterface ;
11
+
12
+ class Item implements BatchServiceContractResolverInterface
13
+ {
14
+ }
15
+ ?>
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © Magento, Inc. All rights reserved.
5
+ * See COPYING.txt for license details.
6
+ */
7
+ -->
2
8
<config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Module/etc/module.xsd" >
3
9
<module name =" Magento_InspectionTest" />
4
10
</config >
Original file line number Diff line number Diff line change 1
1
<?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
2
7
\Magento \Framework \Component \ComponentRegistrar::register (
3
8
\Magento \Framework \Component \ComponentRegistrar::MODULE ,
4
9
'Magento_InspectionTest ' ,
Original file line number Diff line number Diff line change 7
7
import com .intellij .codeInsight .daemon .impl .HighlightInfo ;
8
8
import com .intellij .openapi .util .text .StringUtil ;
9
9
import com .intellij .testFramework .fixtures .BasePlatformTestCase ;
10
+ import com .magento .idea .magento2plugin .bundles .InspectionBundle ;
10
11
import com .magento .idea .magento2plugin .indexes .IndexManager ;
11
12
import com .magento .idea .magento2plugin .project .Settings ;
12
13
import com .magento .idea .magento2plugin .magento .packages .File ;
18
19
abstract public class BaseProjectTestCase extends BasePlatformTestCase {
19
20
private static final String testDataProjectPath = "testData" + File .separator + "project" ;
20
21
private static final String testDataProjectDirectory = "magento2" ;
22
+ protected final InspectionBundle inspectionBundle = new InspectionBundle ();
21
23
22
24
@ Override
23
25
protected void setUp () throws Exception {
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
1
5
package com .magento .idea .magento2plugin .inspections .graphqls ;
2
6
3
7
public class SchemaResolverInspectionTest extends InspectionGraphqlsFixtureTestCase {
4
8
5
- private final String errorMessage = "Class must implements \\ Magento\\ Framework\\ GraphQl\\ Query\\ ResolverInterface" ;
9
+ private final String errorMessage = inspectionBundle .message (
10
+ "inspection.graphql.resolver.mustImplement"
11
+ );
6
12
7
13
@ Override
8
14
public void setUp () throws Exception {
@@ -23,4 +29,16 @@ public void testWithInvalidSchemaResolverInterface() throws Exception {
23
29
myFixture .configureByFile (getFixturePath ("schema.graphqls" ));
24
30
assertHasHighlighting (errorMessage );
25
31
}
32
+
33
+ public void testWithValidBatchResolverInterface () throws Exception {
34
+ myFixture .configureByFile (getFixturePath ("schema.graphqls" ));
35
+
36
+ assertHasNoHighlighting (errorMessage );
37
+ }
38
+
39
+ public void testWithValidBatchServiceContractResolverInterface () throws Exception {
40
+ myFixture .configureByFile (getFixturePath ("schema.graphqls" ));
41
+
42
+ assertHasNoHighlighting (errorMessage );
43
+ }
26
44
}
Original file line number Diff line number Diff line change 8
8
9
9
public class GraphQlResolverInspectionTest extends InspectionPhpFixtureTestCase {
10
10
11
- private final InspectionBundle inspectionBundle = new InspectionBundle ();
12
11
private final String errorMessage = inspectionBundle .message (
13
12
"inspection.graphql.resolver.mustImplement"
14
13
);
You can’t perform that action at this time.
0 commit comments