Skip to content

Commit d79d8f7

Browse files
committed
add unit tests to php-graphql
1 parent a227f4b commit d79d8f7

File tree

7 files changed

+1289
-0
lines changed

7 files changed

+1289
-0
lines changed

phpunit.xml.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php">
6+
<coverage>
7+
<include>
8+
<directory suffix=".php">./src</directory>
9+
</include>
10+
</coverage>
11+
<php>
12+
<ini name="error_reporting" value="E_ALL"/>
13+
</php>
14+
<testsuites>
15+
<testsuite name="joonlabs/php-graphql">
16+
<directory>./tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>

tests/Errors/ErrorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use \PHPUnit\Framework\TestCase;
4+
use \GraphQL\Errors\GraphQLError;
5+
6+
class ErrorTest extends TestCase {
7+
8+
/**
9+
* check if node can be converted into location correctly
10+
*/
11+
public function testConvertNodeToPosition(){
12+
$node = [
13+
// ... more properties of node
14+
"loc" => [
15+
"line" => 1,
16+
"column" => 1,
17+
]
18+
];
19+
$Error = new GraphQLError("message", $node);
20+
self::assertSame($Error->getLocations(), $node["loc"]);
21+
}
22+
23+
24+
}

0 commit comments

Comments
 (0)