Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#118)
by Jérémiah
06:21
created

MutationTest::testSupportsPromiseMutations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 9

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Tests\Functional\Relay\Mutation;
13
14
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
15
16
/**
17
 * Class MutationTest.
18
 *
19
 * @see https://github.com/graphql/graphql-relay-js/blob/master/src/mutation/__tests__/mutation.js
20
 */
21
class MutationTest extends TestCase
22
{
23
    protected function setUp()
24
    {
25
        parent::setUp();
26
27
        static::createAndBootKernel(['test_case' => 'mutation']);
28
    }
29
30
    public function testRequiresAnArgument()
31
    {
32
        $query = <<<'EOF'
33
mutation M {
34
  simpleMutation {
35
    result
36
  }
37
}
38
EOF;
39
        $result = $this->executeGraphQLRequest($query);
40
41
        $this->assertCount(1, $result['errors']);
42
        $this->assertEquals(
43
            'Field "simpleMutation" argument "input" of type "simpleMutationInput!" is required but not provided.',
44
            $result['errors'][0]['message']
45
        );
46
    }
47
48 View Code Duplication
    public function testReturnTheSameClientMutationId()
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...
49
    {
50
        $query = <<<'EOF'
51
mutation M {
52
  simpleMutation(input: {clientMutationId: "abc"}) {
53
    result
54
    clientMutationId
55
  }
56
}
57
EOF;
58
59
        $expectedData = [
60
            'simpleMutation' => [
61
                'result' => 1,
62
                'clientMutationId' => 'abc',
63
            ],
64
        ];
65
66
        $this->assertGraphQL($query, $expectedData);
67
    }
68
69 View Code Duplication
    public function testSupportsThunksAsInputAndOutputFields()
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...
70
    {
71
        $query = <<<'EOF'
72
mutation M {
73
  simpleMutationWithThunkFields(input: {inputData: 1234, clientMutationId: "abc"}) {
74
    result
75
    clientMutationId
76
  }
77
}
78
EOF;
79
        $expectedData = [
80
            'simpleMutationWithThunkFields' => [
81
                'result' => 1234,
82
                'clientMutationId' => 'abc',
83
            ],
84
        ];
85
86
        $this->assertGraphQL($query, $expectedData);
87
    }
88
89 View Code Duplication
    public function testSupportsPromiseMutations()
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...
90
    {
91
        $query = <<<'EOF'
92
mutation M {
93
  simplePromiseMutation(input: {clientMutationId: "abc"}) {
94
    result
95
    clientMutationId
96
  }
97
}
98
EOF;
99
        $expectedData = [
100
            'simplePromiseMutation' => [
101
                'result' => 1,
102
                'clientMutationId' => 'abc',
103
            ],
104
        ];
105
106
        $this->assertGraphQL($query, $expectedData);
107
    }
108
109
    public function testContainsCorrectInput()
110
    {
111
        $query = <<<'EOF'
112
{
113
  __type(name: "simpleMutationInput") {
114
    name
115
    kind
116
    inputFields {
117
      name
118
      type {
119
        name
120
        kind
121
      }
122
    }
123
  }
124
}
125
EOF;
126
        $expectedData = [
127
            '__type' => [
128
                'name' => 'simpleMutationInput',
129
                'kind' => 'INPUT_OBJECT',
130
                'inputFields' => [
131
                    [
132
                        'name' => 'clientMutationId',
133
                        'type' => [
134
                            'name' => 'String',
135
                            'kind' => 'SCALAR',
136
                        ],
137
                    ],
138
                ],
139
            ],
140
        ];
141
142
        $this->assertGraphQL($query, $expectedData);
143
    }
144
145
    public function testContainsCorrectPayload()
146
    {
147
        $query = <<<'EOF'
148
{
149
  __type(name: "simpleMutationPayload") {
150
    name
151
    kind
152
    fields {
153
      name
154
      type {
155
        name
156
        kind
157
      }
158
    }
159
  }
160
}
161
EOF;
162
163
        $expectedData = [
164
            '__type' => [
165
                'name' => 'simpleMutationPayload',
166
                'kind' => 'OBJECT',
167
                'fields' => [
168
                    [
169
                        'name' => 'result',
170
                        'type' => [
171
                            'name' => 'Int',
172
                            'kind' => 'SCALAR',
173
                        ],
174
                    ],
175
                    [
176
                        'name' => 'clientMutationId',
177
                        'type' => [
178
                            'name' => 'String',
179
                            'kind' => 'SCALAR',
180
                        ],
181
                    ],
182
183
                ],
184
            ],
185
        ];
186
187
        $this->assertGraphQL($query, $expectedData);
188
    }
189
190
    public function testContainsCorrectField()
191
    {
192
        $query = <<<'EOF'
193
{
194
  __schema {
195
    mutationType {
196
      fields {
197
        name
198
        args {
199
          name
200
          type {
201
            name
202
            kind
203
            ofType {
204
              name
205
              kind
206
            }
207
          }
208
        }
209
        type {
210
          name
211
          kind
212
        }
213
      }
214
    }
215
  }
216
}
217
EOF;
218
219
        $expectedData = [
220
            '__schema' => [
221
                'mutationType' => [
222
                    'fields' => [
223
                        [
224
                            'name' => 'simpleMutation',
225
                            'args' => [
226
                                [
227
                                    'name' => 'input',
228
                                    'type' => [
229
                                        'name' => null,
230
                                        'kind' => 'NON_NULL',
231
                                        'ofType' => [
232
                                            'name' => 'simpleMutationInput',
233
                                            'kind' => 'INPUT_OBJECT',
234
                                        ],
235
                                    ],
236
                                ],
237
                            ],
238
                            'type' => [
239
                                'name' => 'simpleMutationPayload',
240
                                'kind' => 'OBJECT',
241
                            ],
242
                        ],
243
                        [
244
                            'name' => 'simpleMutationWithThunkFields',
245
                            'args' => [
246
                                [
247
                                    'name' => 'input',
248
                                    'type' => [
249
                                        'name' => null,
250
                                        'kind' => 'NON_NULL',
251
                                        'ofType' => [
252
                                            'name' => 'simpleMutationWithThunkFieldsInput',
253
                                            'kind' => 'INPUT_OBJECT',
254
                                        ],
255
                                    ],
256
                                ],
257
                            ],
258
                            'type' => [
259
                                'name' => 'simpleMutationWithThunkFieldsPayload',
260
                                'kind' => 'OBJECT',
261
                            ],
262
                        ],
263
                        [
264
                            'name' => 'simplePromiseMutation',
265
                            'args' => [
266
                                [
267
                                    'name' => 'input',
268
                                    'type' => [
269
                                        'name' => null,
270
                                        'kind' => 'NON_NULL',
271
                                        'ofType' => [
272
                                            'name' => 'simplePromiseMutationInput',
273
                                            'kind' => 'INPUT_OBJECT',
274
                                        ],
275
                                    ],
276
                                ],
277
                            ],
278
                            'type' => [
279
                                'name' => 'simplePromiseMutationPayload',
280
                                'kind' => 'OBJECT',
281
                            ],
282
                        ],
283
                    ],
284
                ],
285
            ],
286
        ];
287
288
        $this->assertGraphQL($query, $expectedData);
289
    }
290
}
291