Completed
Pull Request — master (#379)
by Beñat
04:29
created

CreateTaskMutationTest::tearDownChangedDbData()   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\Mutation\Project\Task;
16
17
use Lakion\ApiTestCase\JsonApiTestCase;
18
19
class CreateTaskMutationTest extends JsonApiTestCase
20
{
21
    /**
22
     * @afterClass
23
     */
24
    public static function tearDownChangedDbData() : void
25
    {
26
        exec("sh etc/bash/install_test_env.sh");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal sh etc/bash/install_test_env.sh does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
27
    }
28
29 View Code Duplication
    public function testNonexistentTaskParentMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        $this->createTaskMutation(
32
            'access-token-1',
33
            [
34
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1f',
35
                'title'            => 'The task title',
36
                'description'      => 'The task description',
37
                'assigneeId'       => '1106e034-d6b8-46c0-a393-9f0fd92d18a1',
38
                'priority'         => 'HIGH',
39
                'projectId'        => '0dadad5e-1220-11e7-93ae-92361f002671',
40
                'parentId'         => 'nonexistent-parent-task-id',
41
            ],
42
            '/create_task_with_nonexistent_parent'
43
        );
44
    }
45
46 View Code Duplication
    public function testNonexistentProjectMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $this->createTaskMutation(
49
            'access-token-1',
50
            [
51
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1f',
52
                'title'            => 'The task title',
53
                'description'      => 'The task description',
54
                'assigneeId'       => '1106e034-d6b8-46c0-a393-9f0fd92d18a1',
55
                'priority'         => 'HIGH',
56
                'projectId'        => 'nonexistent-project-id',
57
                'parentId'         => null,
58
            ],
59
            '/create_task_with_nonexistent_project'
60
        );
61
    }
62
63 View Code Duplication
    public function testNotMemberAssigneeMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $this->createTaskMutation(
66
            'access-token-1',
67
            [
68
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1f',
69
                'title'            => 'The task title',
70
                'description'      => 'The task description',
71
                'assigneeId'       => '8eb29ed7-93b2-4c94-bb9b-ad4b323ad8c5',
72
                'priority'         => 'HIGH',
73
                'projectId'        => '0dadad5e-1220-11e7-93ae-92361f002671',
74
                'parentId'         => null,
75
            ],
76
            '/create_task_with_not_member_assignee'
77
        );
78
    }
79
80 View Code Duplication
    public function testUnauthorizedTaskCreationMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
    {
82
        $this->createTaskMutation(
83
            'access-token-2',
84
            [
85
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1f',
86
                'title'            => 'The task title',
87
                'description'      => 'The task description',
88
                'assigneeId'       => '1106e034-d6b8-46c0-a393-9f0fd92d18a1',
89
                'priority'         => 'HIGH',
90
                'projectId'        => '0dadad5e-1220-11e7-93ae-92361f002671',
91
                'parentId'         => null,
92
            ],
93
            '/create_task_with_not_member_creator'
94
        );
95
    }
96
97 View Code Duplication
    public function testCreateTaskMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    {
99
        $this->createTaskMutation(
100
            'access-token-1',
101
            [
102
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1f',
103
                'title'            => 'The task title',
104
                'description'      => 'The task description',
105
                'assigneeId'       => '1106e034-d6b8-46c0-a393-9f0fd92d18a1',
106
                'priority'         => 'HIGH',
107
                'projectId'        => '0dadad5e-1220-11e7-93ae-92361f002671',
108
                'parentId'         => null,
109
            ],
110
            '/create_task'
111
        );
112
    }
113
114 View Code Duplication
    public function testCreateTaskWithParentMutation() : void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
115
    {
116
        $this->createTaskMutation(
117
            'access-token-1',
118
            [
119
                'clientMutationId' => '5c9fd085-cdda-49de-9272-39f304e3bd1z',
120
                'title'            => 'The task title with parent',
121
                'description'      => 'The task description with parent',
122
                'assigneeId'       => '1106e034-d6b8-46c0-a393-9f0fd92d18a1',
123
                'priority'         => 'MEDIUM',
124
                'projectId'        => '0dadad5e-1220-11e7-93ae-92361f002671',
125
                'parentId'         => '42eb4c4c-1225-11e7-93ae-92361f002671',
126
            ],
127
            '/create_task_with_parent'
128
        );
129
    }
130
131
    private function createTaskMutation(string $token, array $input, string $jsonResult) : void
132
    {
133
        $this->client->request('POST', '/?access_token=' . $token, [
134
            'query'       => <<<EOF
135
mutation CreateTaskMutation(\$input: CreateTaskInput!) {
136
  createTask(input: \$input) {
137
    task {
138
      id
139
      title,
140
      description,
141
      numeric_id,
142
      progress,
143
      priority,
144
      parent_task {
145
        id,
146
        title,
147
        numeric_id
148
      },
149
      assignee {
150
        id
151
      },
152
      creator {
153
        id
154
      },
155
      project {
156
        id,
157
        name,
158
        slug,
159
        organization {
160
          id,
161
          slug
162
        }
163
      }
164
    }
165
  }
166
}
167
EOF
168
            , 'variables' => ['input' => $input],
169
        ]);
170
        $response = $this->client->getResponse();
171
172
        $this->assertResponse($response, 'graphql/mutation/project/task' . $jsonResult);
173
    }
174
}
175