|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Kreta package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
|
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace Kreta\TaskManager\Tests\Integration\GraphQl\Query; |
|
16
|
|
|
|
|
17
|
|
|
use Lakion\ApiTestCase\JsonApiTestCase; |
|
18
|
|
|
|
|
19
|
|
|
class OrganizationsResolverTest extends JsonApiTestCase |
|
20
|
|
|
{ |
|
21
|
|
|
public function testOrganizationsResolver() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->organizationsResolver( |
|
24
|
|
|
'access-token-1', |
|
25
|
|
|
[ |
|
26
|
|
|
'name' => '', |
|
27
|
|
|
], |
|
28
|
|
|
'/organizations' |
|
29
|
|
|
); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testOrganizationsFilteredByNameResolver() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->organizationsResolver( |
|
35
|
|
|
'access-token-1', |
|
36
|
|
|
[ |
|
37
|
|
|
'name' => '2', |
|
38
|
|
|
], |
|
39
|
|
|
'/organizations_filtered' |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testOrganizationsWithAfter3AndFirst2() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->organizationsResolver( |
|
46
|
|
|
'access-token-1', |
|
47
|
|
|
[ |
|
48
|
|
|
'after' => '3', |
|
49
|
|
|
'first' => '2', |
|
50
|
|
|
], |
|
51
|
|
|
'/organizations_paginated' |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testOrganizationsWithOtherUserResolver() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->organizationsResolver( |
|
58
|
|
|
'access-token-2', |
|
59
|
|
|
[ |
|
60
|
|
|
'name' => '', |
|
61
|
|
|
], |
|
62
|
|
|
'/organizations_of_user2' |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
private function organizationsResolver($token, $organizationConnectionInput, $jsonResult) |
|
67
|
|
|
{ |
|
68
|
|
|
$this->client->request('POST', '/?access_token=' . $token, [ |
|
69
|
|
|
'query' => <<<EOF |
|
70
|
|
|
query OrganizationsQueryRequest(\$organizationConnectionInput: OrganizationConnectionInput!) { |
|
71
|
|
|
organizations(organizationConnectionInput: \$organizationConnectionInput) { |
|
72
|
|
|
totalCount, |
|
73
|
|
|
edges { |
|
74
|
|
|
node { |
|
75
|
|
|
id, |
|
76
|
|
|
name, |
|
77
|
|
|
slug, |
|
78
|
|
|
owners { |
|
79
|
|
|
id |
|
80
|
|
|
} |
|
81
|
|
|
projects(first: -1) { |
|
82
|
|
|
totalCount, |
|
83
|
|
|
pageInfo { |
|
84
|
|
|
hasNextPage |
|
85
|
|
|
}, |
|
86
|
|
|
edges { |
|
87
|
|
|
node { |
|
88
|
|
|
id, |
|
89
|
|
|
name, |
|
90
|
|
|
slug, |
|
91
|
|
|
organization { |
|
92
|
|
|
slug |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
EOF |
|
102
|
|
|
, 'variables' => ['organizationConnectionInput' => $organizationConnectionInput], |
|
103
|
|
|
]); |
|
104
|
|
|
|
|
105
|
|
|
$response = $this->client->getResponse(); |
|
106
|
|
|
|
|
107
|
|
|
$this->assertResponse($response, 'graphql/query/organization' . $jsonResult); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|