Skip to content

Commit ae5b96e

Browse files
author
Jeremiah VALERIE
committed
Add multiple queries tests
1 parent baeba49 commit ae5b96e

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
imports:
2+
- { resource: ../config.yml }
3+
- { resource: ../exception/services.yml }
4+
5+
overblog_graphql:
6+
definitions:
7+
class_namespace: "Overblog\\GraphQLBundle\\MultipleQueries\\__DEFINITIONS__"
8+
schema:
9+
query: RootQuery
10+
mutation: RootQuery
11+
mappings:
12+
types:
13+
-
14+
type: yaml
15+
dir: "%kernel.root_dir%/config/multipleQueries/mapping"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
RootQuery:
2+
type: object
3+
config:
4+
fields:
5+
failRequire:
6+
type: String!
7+
resolve: '@=resolver("example_exception")'
8+
failOptional:
9+
type: String
10+
resolve: '@=resolver("example_exception")'
11+
success:
12+
type: String
13+
resolve: 'foo'
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace Overblog\GraphQLBundle\Tests\Functional\MultipleQueries;
4+
5+
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
6+
7+
class MultipleQueriesTest extends TestCase
8+
{
9+
const REQUIRED_FAILS = [
10+
'data' => [],
11+
'errors' => [
12+
[
13+
'message' => 'Internal server Error',
14+
'category' => 'internal',
15+
'locations' => [
16+
[
17+
'line' => 2,
18+
'column' => 3,
19+
],
20+
],
21+
'path' => [
22+
'fail',
23+
],
24+
],
25+
],
26+
];
27+
28+
const OPTIONAL_FAILS = [
29+
'data' => [
30+
'fail' => null,
31+
'success' => 'foo',
32+
],
33+
'errors' => [
34+
[
35+
'message' => 'Internal server Error',
36+
'category' => 'internal',
37+
'locations' => [
38+
[
39+
'line' => 2,
40+
'column' => 3,
41+
],
42+
],
43+
'path' => [
44+
'fail',
45+
],
46+
],
47+
],
48+
];
49+
50+
protected function setUp()
51+
{
52+
parent::setUp();
53+
54+
static::bootKernel(['test_case' => 'multipleQueries']);
55+
}
56+
57+
public function testRequiredFails()
58+
{
59+
$query = <<<'EOF'
60+
{
61+
fail: failRequire
62+
success: success
63+
}
64+
EOF;
65+
$result = $this->executeGraphQLRequest($query);
66+
$this->assertEquals(self::REQUIRED_FAILS, $result);
67+
}
68+
69+
public function testOptionalFails()
70+
{
71+
$query = <<<'EOF'
72+
{
73+
fail: failOptional
74+
success: success
75+
}
76+
EOF;
77+
$result = $this->executeGraphQLRequest($query);
78+
$this->assertEquals(self::OPTIONAL_FAILS, $result);
79+
}
80+
81+
public function testMutationRequiredFails()
82+
{
83+
$query = <<<'EOF'
84+
mutation {
85+
fail: failRequire
86+
success: success
87+
}
88+
EOF;
89+
$result = $this->executeGraphQLRequest($query);
90+
$this->assertEquals(self::REQUIRED_FAILS, $result);
91+
}
92+
93+
public function testMutationOptionalFails()
94+
{
95+
$query = <<<'EOF'
96+
mutation {
97+
fail: failOptional
98+
success: success
99+
}
100+
EOF;
101+
$result = $this->executeGraphQLRequest($query);
102+
$this->assertEquals(self::OPTIONAL_FAILS, $result);
103+
}
104+
}

0 commit comments

Comments
 (0)