Skip to content

Commit 970c129

Browse files
author
Vitaliy Boyko
committed
Refactored tests, added class do not exist warning
1 parent 084c4ff commit 970c129

File tree

16 files changed

+38
-76
lines changed

16 files changed

+38
-76
lines changed

resources/magento2/inspection.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
inspection.class.hierarchyImplementationCheck=Class must implement {0}
2-
inspection.class.hierarchyExtendingCheck=Class must extend {0}
31
inspection.plugin.duplicateInSameFile=The plugin name already used in this file. For more details see Inspection Description.
42
inspection.plugin.duplicateInOtherPlaces=The plugin name "{0}" for targeted "{1}" class is already used in the module "{2}" ({3} scope). For more details see Inspection Description.
53
inspection.graphql.resolver.mustImplement=Class must implements any of the following interfaces: \\Magento\\Framework\\GraphQl\\Query\\ResolverInterface, \\Magento\\Framework\\GraphQl\\Query\\Resolver\\BatchResolverInterface, \\Magento\\Framework\\GraphQl\\Query\\Resolver\\BatchServiceContractResolverInterface
4+
inspection.graphql.resolver.notExist=Resolver class do not exist
65
inspection.graphql.resolver.fix.family=Implement Resolver interface
76
inspection.graphql.resolver.fix.title=Select one of the following interface
87
inspection.plugin.error.nonPublicMethod=You can't declare a plugin for a not public method.

src/com/magento/idea/magento2plugin/inspections/graphqls/SchemaResolverInspection.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ public void visitValue(@NotNull GraphQLValue element) {
3535
GetPhpClassByFQN getPhpClassByFQN = GetPhpClassByFQN.getInstance(holder.getProject());
3636
PhpClass resolverClass = getPhpClassByFQN.execute(resolverFQN);
3737
if (resolverClass == null) {
38+
holder.registerProblem(element,
39+
inspectionBundle.message(
40+
"inspection.graphql.resolver.notExist"
41+
),
42+
ProblemHighlightType.ERROR);
3843
return;
3944
}
4045
if (!GraphQlUtil.isResolver(resolverClass)) {
4146
holder.registerProblem(element,
42-
inspectionBundle.message(
43-
"inspection.graphql.resolver.mustImplement"
44-
),
45-
ProblemHighlightType.ERROR);
47+
inspectionBundle.message(
48+
"inspection.graphql.resolver.mustImplement"
49+
),
50+
ProblemHighlightType.ERROR);
4651
}
4752
}
4853
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.magento.files;
6+
7+
public class GraphQLSchema {
8+
public static String FILE_NAME = "schema.graphqls";
9+
}

testData/inspections/graphqls/SchemaResolverInspection/withInvalidSchemaResolverInterface/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# See COPYING.txt for license details.
33

44
type Query {
5-
test(input: test!): test @resolver(class: "\\Magento\\InspectionTest\\Model\\GraphQl\\WithInvalidSchemaResolverInterface\\Item") @doc(description: "Test")
5+
test(input: test!): test @resolver(class: "\\Magento\\Backend\\Model\\Source\\YesNo") @doc(description: "Test")
66
}

testData/inspections/graphqls/SchemaResolverInspection/withValidBatchResolverInterface/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# See COPYING.txt for license details.
33

44
type Query {
5-
test(input: test!): test @resolver(class: "\\Magento\\InspectionTest\\Model\\GraphQl\\WithValidBatchResolverInterface\\Item") @doc(description: "Test")
5+
test(input: test!): test @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\ImplementsBatchResolverInterface") @doc(description: "Test")
66
}

testData/inspections/graphqls/SchemaResolverInspection/withValidBatchServiceContractResolverInterface/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# See COPYING.txt for license details.
33

44
type Query {
5-
test(input: test!): test @resolver(class: "\\Magento\\InspectionTest\\Model\\GraphQl\\WithValidBatchServiceContractResolverInterface\\Item") @doc(description: "Test")
5+
test(input: test!): test @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\ImplementsBatchServiceContractResolverInterface") @doc(description: "Test")
66
}

testData/inspections/graphqls/SchemaResolverInspection/withValidSchemaResolverInterface/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# See COPYING.txt for license details.
33

44
type Query {
5-
test(input: test!): test @resolver(class: "\\Magento\\InspectionTest\\Model\\GraphQl\\WithValidSchemaResolverInterface\\Item") @doc(description: "Test")
5+
test(input: test!): test @resolver(class: "\\Magento\\CatalogGraphQl\\Model\\Resolver\\ImplementsResolverInterface") @doc(description: "Test")
66
}

testData/project/magento2/app/code/Magento/InspectionTest/Model/GraphQl/WithInvalidSchemaResolverInterface/Item.php

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

testData/project/magento2/app/code/Magento/InspectionTest/composer.json

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

testData/project/magento2/app/code/Magento/InspectionTest/etc/module.xml

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

0 commit comments

Comments
 (0)