Completed
Push — master ( 69c2b9...604983 )
by Beñat
16s
created

testTasksWithOtherUserResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Project\Task;
16
17
use Lakion\ApiTestCase\JsonApiTestCase;
18
19
class TasksResolverTest extends JsonApiTestCase
20
{
21
    public function testTasksResolver() : void
22
    {
23
        $this->tasksResolver('access-token-2', [], '/tasks');
24
    }
25
26
    public function testTasksFilteredByTitleResolver() : void
27
    {
28
        $this->tasksResolver('access-token-2', ['title' => 'Task 1'], '/tasks_filtered_by_title');
29
    }
30
31
    public function testTasksFilteredByParentResolver() : void
32
    {
33
        $this->tasksResolver('access-token-2', [
34
            'parentId' => '42eb534a-1225-11e7-93ae-92361f002671',
35
        ], '/tasks_filtered_by_parent');
36
    }
37
38
    public function testTasksFilteredByProjectResolver() : void
39
    {
40
        $this->tasksResolver('access-token-2', [
41
            'projectId' => '0dadb844-1220-11e7-93ae-92361f002671',
42
        ], '/tasks_filtered_by_project');
43
    }
44
45
    public function testTasksFilteredByPriorityResolver() : void
46
    {
47
        $this->tasksResolver('access-token-2', ['priority' => 'MEDIUM'], '/tasks_filtered_by_priority');
48
    }
49
50
    public function testTasksFilteredByProgressResolver() : void
51
    {
52
        $this->tasksResolver('access-token-2', ['progress' => 'DOING'], '/tasks_filtered_by_progress');
53
    }
54
55
    public function testTasksFilteredByAssigneeResolver() : void
56
    {
57
        $this->tasksResolver('access-token-2', [
58
            'assigneeId' => '6704c278-e106-449f-a73d-2508e96f6177',
59
        ], '/tasks_filtered_by_assignee');
60
    }
61
62
    public function testTasksFilteredByCreatorResolver() : void
63
    {
64
        $this->tasksResolver('access-token-2', [
65
            'creatorId' => '6704c278-e106-449f-a73d-2508e96f6177',
66
        ], '/tasks_filtered_by_creator');
67
    }
68
69
    public function testTasksFilteredByMultipleResolver() : void
70
    {
71
        $this->tasksResolver('access-token-2', [
72
            'creatorId' => '6704c278-e106-449f-a73d-2508e96f6177',
73
            'priority'  => 'MEDIUM',
74
            'progress'  => 'DOING',
75
        ], '/tasks_filtered_by_multiple');
76
    }
77
78
    public function testTasksWithAfter3AndFirst2() : void
79
    {
80
        $this->tasksResolver('access-token-2', ['after' => '3', 'first' => '2'], '/tasks_paginated');
81
    }
82
83
    public function testTasksWithOtherUserResolver() : void
84
    {
85
        $this->tasksResolver('access-token-1', [], '/tasks_of_user2');
86
    }
87
88
    private function tasksResolver(string $token, array $taskConnectionInput, string $jsonResult) : void
89
    {
90
        $this->client->request('POST', '/?access_token=' . $token, [
91
            'query'       => <<<EOF
92
query TasksQueryRequest(\$taskConnectionInput: TaskConnectionInput!) {
93
  tasks(taskConnectionInput: \$taskConnectionInput) {
94
    totalCount,
95
    edges {
96
      node {
97
        id
98
        title,
99
        description,
100
        numeric_id,
101
        priority,
102
        progress,
103
        assignee {
104
          id
105
        },
106
        creator {
107
          id
108
        },
109
        project {
110
          id,
111
          name,
112
          slug
113
        },
114
      }
115
      cursor
116
    },
117
    pageInfo {
118
      endCursor,
119
      hasNextPage
120
    }
121
  }
122
}
123
EOF
124
            , 'variables' => ['taskConnectionInput' => $taskConnectionInput],
125
        ]);
126
127
        $response = $this->client->getResponse();
128
129
        $this->assertResponse($response, 'graphql/query/project/task' . $jsonResult);
130
    }
131
}
132