-
-
Notifications
You must be signed in to change notification settings - Fork 600
/
Copy pathGraphQLTest.php
58 lines (47 loc) · 1.26 KB
/
GraphQLTest.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
<?php
namespace Github\Tests\Api;
class GraphQLTest extends TestCase
{
/**
* @test
*/
public function shouldTestGraphQL()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with($this->equalTo('/graphql'), $this->equalTo(['query' => 'bar']))
->will($this->returnValue('foo'));
$result = $api->execute('bar');
$this->assertEquals('foo', $result);
}
/**
* @test
*/
public function shouldSupportGraphQLVariables()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/graphql', $this->arrayHasKey('variables'));
$api->execute('bar', ['variable' => 'foo']);
}
/**
* @test
*/
public function shouldJSONEncodeGraphQLVariables()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('/graphql', $this->equalTo([
'query' => 'bar',
'variables' => '{"variable":"foo"}',
]));
$api->execute('bar', ['variable' => 'foo']);
}
protected function getApiClass()
{
return \Github\Api\GraphQL::class;
}
}