-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathWithTypeTest.php
66 lines (59 loc) · 1.59 KB
/
WithTypeTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\WithTypeTests;
use Rebing\GraphQL\Tests\TestCase;
class WithTypeTest extends TestCase
{
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);
$app['config']->set('graphql.schemas.default', [
'query' => [
PostMessagesQuery::class,
],
]);
$app['config']->set('graphql.types', [
SimpleMessageType::class,
PostType::class,
]);
}
public function testPostMessagesQuery(): void
{
$query = <<<'GRAQPHQL'
{
postMessages {
data {
post_id
title
}
messages {
message
type
}
}
}
GRAQPHQL;
$result = $this->httpGraphql($query);
$expectedResult = [
'data' => [
'postMessages' => [
'data' => [
'post_id' => 1,
'title' => 'This is the title post',
],
'messages' => [
[
'message' => 'Congratulations, the post was found',
'type' => 'success',
],
[
'message' => 'This post cannot be edited", "warning',
'type' => 'success',
],
],
],
],
];
self::assertSame($expectedResult, $result);
}
}