Skip to content

Commit ff26c2a

Browse files
Test added for graphql resolver inspection
1 parent d577b27 commit ff26c2a

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 11 additions & 0 deletions
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+
namespace Magento\Test;
7+
use Magento\Framework\GraphQl\Query\InvalidInterface;
8+
class <error descr="Class must implements \Magento\Framework\GraphQl\Query\ResolverInterface">InvalidResolverTest</error> implements InvalidInterface
9+
{
10+
}
11+
?>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Test;
7+
class ValidResolverTest implements \Magento\Framework\GraphQl\Query\ResolverInterface
8+
{
9+
}
10+
?>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.inspections.php;
6+
7+
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
8+
import java.io.File;
9+
10+
public class GraphQlResolverInspectionTest extends BasePlatformTestCase {
11+
12+
@Override
13+
public void setUp() throws Exception {
14+
super.setUp();
15+
myFixture.enableInspections(GraphQlResolverInspection.class);
16+
}
17+
18+
@Override
19+
protected String getTestDataPath() {
20+
return new File("testData/inspections/php/"
21+
+ getClass().getSimpleName().replace("Test", "")).getAbsolutePath();
22+
}
23+
24+
@Override
25+
protected boolean isWriteActionRequired() {
26+
return false;
27+
}
28+
29+
public void testWithInvalidResolverInterface() throws Exception {
30+
myFixture.addFileToProject(getTestDataPath() + "/" + "schema.graphqls", "type Query {" +
31+
"InvalidResolverTest: InvalidResolver @resolver(class: \"\\\\Magento\\\\Test\\\\InvalidResolverTest\")" +
32+
"}");
33+
myFixture.configureByFile(getTestName(true) + "/" + "InvalidResolverTest.php");
34+
myFixture.checkHighlighting();
35+
}
36+
37+
public void testWithValidResolverInterface() throws Exception {
38+
myFixture.addFileToProject(getTestDataPath() + "/" + "schema.graphqls", "type mutation {" +
39+
" ValidResolverTest(): ValidResolver @resolver(class: \"\\\\Magento\\\\Test\\\\ValidResolverTest\")" +
40+
"}");
41+
myFixture.configureByFile(getTestName(true) + "/" + "ValidResolverTest.php");
42+
myFixture.checkHighlighting();
43+
}
44+
}

0 commit comments

Comments
 (0)