Completed
Push — master ( 44b3f2...31d5aa )
by Beñat
15s
created

TaskResolverTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 53
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testNonExistTaskByIdResolver() 0 4 1
A testTaskByIdResolver() 0 4 1
A testTaskWithOtherUserResolver() 0 8 1
B taskResolver() 0 31 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 TaskResolverTest extends JsonApiTestCase
20
{
21
    public function testNonExistTaskByIdResolver() : void
22
    {
23
        $this->taskResolver('access-token-1', 'non-exist-task-id', '/nonexistent_task_by_id');
24
    }
25
26
    public function testTaskByIdResolver() : void
27
    {
28
        $this->taskResolver('access-token-1', '42eb4472-1225-11e7-93ae-92361f002671', '/task');
29
    }
30
31
    public function testTaskWithOtherUserResolver() : void
32
    {
33
        $this->taskResolver(
34
            'access-token-2',
35
            '42eb4472-1225-11e7-93ae-92361f002671',
36
            '/task_with_other_user'
37
        );
38
    }
39
40
    private function taskResolver(string $token, string $id, string $jsonResult) : void
41
    {
42
        $this->client->request('POST', '/?access_token=' . $token, [
43
            'query'       => <<<EOF
44
query TaskQueryRequest(\$id: ID!) {
45
  task(id: \$id) {
46
    id
47
    title,
48
    description,
49
    numeric_id,
50
    priority,
51
    progress,
52
    assignee {
53
      id
54
    },
55
    creator {
56
      id
57
    },
58
    project {
59
      id,
60
      name,
61
      slug
62
    }
63
  }
64
}
65
EOF
66
            , 'variables' => ['id' => $id],
67
        ]);
68
        $response = $this->client->getResponse();
69
        $this->assertResponse($response, 'graphql/query/project/task' . $jsonResult);
70
    }
71
}
72