Completed
Pull Request — master (#372)
by Beñat
04:33
created

TasksResolverTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 98
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testTasksResolver() 0 4 1
A testTasksFilteredByTitleResolver() 0 4 1
A testTasksFilteredByParentResolver() 0 6 1
A testTasksFilteredByPriorityResolver() 0 4 1
A testTasksFilteredByProgressResolver() 0 4 1
A testTasksWithAfter3AndFirst2() 0 4 1
A testTasksWithOtherUserResolver() 0 4 1
B tasksResolver() 0 43 1
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\Task\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
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
//    {
40
//        $this->tasksResolver('access-token-2', ['projectId' => 'Task 1'], '/tasks_filtered_by_project');
41
//    }
42
43
    public function testTasksFilteredByPriorityResolver() : void
44
    {
45
        $this->tasksResolver('access-token-2', ['priority' => 'MEDIUM'], '/tasks_filtered_by_priority');
46
    }
47
48
    public function testTasksFilteredByProgressResolver() : void
49
    {
50
        $this->tasksResolver('access-token-2', ['progress' => 'TODO'], '/tasks_filtered_by_progress');
51
    }
52
53
//    public function testTasksFilteredByAssigneeResolver() : void
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
//    {
55
//        $this->tasksResolver('access-token-2', ['assigneeId' => ''], '/tasks_filtered_by_assignee');
56
//    }
57
//
58
//    public function testTasksFilteredByCreatorResolver() : void
59
//    {
60
//        $this->tasksResolver('access-token-2', ['creatorId' => ''], '/tasks_filtered_by_creator');
61
//    }
62
63
    public function testTasksWithAfter3AndFirst2() : void
64
    {
65
        $this->tasksResolver('access-token-2', ['after' => '3', 'first' => '2'], '/tasks_paginated');
66
    }
67
68
    public function testTasksWithOtherUserResolver() : void
69
    {
70
        $this->tasksResolver('access-token-1', [], '/tasks_of_user2');
71
    }
72
73
    private function tasksResolver(string $token, array $taskConnectionInput, string $jsonResult) : void
74
    {
75
        $this->client->request('POST', '/?access_token=' . $token, [
76
            'query'       => <<<EOF
77
query TasksQueryRequest(\$taskConnectionInput: TaskConnectionInput!) {
78
  tasks(taskConnectionInput: \$taskConnectionInput) {
79
    totalCount,
80
    edges {
81
      node {
82
        id
83
        title,
84
        description,
85
        numeric_id,
86
        priority,
87
        progress,
88
        assignee {
89
          id
90
        },
91
        creator {
92
          id
93
        },
94
        project {
95
          id,
96
          name,
97
          slug
98
        },
99
      }
100
      cursor
101
    },
102
    pageInfo {
103
      endCursor,
104
      hasNextPage
105
    }
106
  }
107
}
108
EOF
109
            , 'variables' => ['taskConnectionInput' => $taskConnectionInput],
110
        ]);
111
112
        $response = $this->client->getResponse();
113
114
        $this->assertResponse($response, 'graphql/query/project/task' . $jsonResult);
115
    }
116
}
117