Skip to content

Commit c419da2

Browse files
author
Vitaliy
authored
Merge pull request #138 from konarshankar07/test-covered-for-graphql-resolver--task-115
#115 : Tests. Cover the PHP GraphQL resolver inspection by tests
2 parents 980b5ff + 56a4104 commit c419da2

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
public class GraphQlResolverInspectionTest extends InspectionPhpFixtureTestCase {
8+
9+
@Override
10+
public void setUp() throws Exception {
11+
super.setUp();
12+
myFixture.enableInspections(GraphQlResolverInspection.class);
13+
}
14+
15+
@Override
16+
protected boolean isWriteActionRequired() {
17+
return false;
18+
}
19+
20+
public void testWithInvalidResolverInterface() throws Exception {
21+
myFixture.addFileToProject("schema.graphqls", "type Query {" +
22+
"InvalidResolverTest: InvalidResolver @resolver(class: \"\\\\Magento\\\\Test\\\\InvalidResolverTest\")" +
23+
"}");
24+
myFixture.configureByFile(getFixturePath("InvalidResolverTest.php"));
25+
myFixture.checkHighlighting();
26+
}
27+
28+
public void testWithValidResolverInterface() throws Exception {
29+
myFixture.addFileToProject("schema.graphqls", "type mutation {" +
30+
" ValidResolverTest(): ValidResolver @resolver(class: \"\\\\Magento\\\\Test\\\\ValidResolverTest\")" +
31+
"}");
32+
myFixture.configureByFile(getFixturePath("ValidResolverTest.php"));
33+
myFixture.checkHighlighting();
34+
}
35+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.magento.idea.magento2plugin.inspections.php;
2+
3+
import com.magento.idea.magento2plugin.BaseProjectTestCase;
4+
5+
import java.io.File;
6+
7+
abstract public class InspectionPhpFixtureTestCase extends BaseProjectTestCase {
8+
9+
private static final String testDataFolderPath = "testData" + File.separator + "inspections" + File.separator;
10+
private static final String fixturesFolderPath = "php" + File.separator;
11+
12+
@Override
13+
protected void setUp() throws Exception {
14+
super.setUp();
15+
myFixture.setTestDataPath(testDataFolderPath);
16+
}
17+
18+
@Override
19+
protected boolean isWriteActionRequired() {
20+
return false;
21+
}
22+
23+
protected String getFixturePath(String fileName) {
24+
return prepareFixturePath(fileName, fixturesFolderPath);
25+
}
26+
}

0 commit comments

Comments
 (0)