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 (#79)
by Jérémiah
04:44
created

MutationTest::testContainsCorrectPayload()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 44
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 18
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
    public function testContainsCorrectInput()
90
    {
91
        $query = <<<'EOF'
92
{
93
  __type(name: "simpleMutationInput") {
94
    name
95
    kind
96
    inputFields {
97
      name
98
      type {
99
        name
100
        kind
101
      }
102
    }
103
  }
104
}
105
EOF;
106
        $expectedData = [
107
            '__type' => [
108
                'name' => 'simpleMutationInput',
109
                'kind' => 'INPUT_OBJECT',
110
                'inputFields' => [
111
                    [
112
                        'name' => 'clientMutationId',
113
                        'type' => [
114
                            'name' => 'String',
115
                            'kind' => 'SCALAR',
116
                        ],
117
                    ],
118
                ],
119
            ],
120
        ];
121
122
        $this->assertGraphQL($query, $expectedData);
123
    }
124
125
    public function testContainsCorrectPayload()
126
    {
127
        $query = <<<'EOF'
128
{
129
  __type(name: "simpleMutationPayload") {
130
    name
131
    kind
132
    fields {
133
      name
134
      type {
135
        name
136
        kind
137
      }
138
    }
139
  }
140
}
141
EOF;
142
143
        $expectedData = [
144
            '__type' => [
145
                'name' => 'simpleMutationPayload',
146
                'kind' => 'OBJECT',
147
                'fields' => [
148
                    [
149
                        'name' => 'result',
150
                        'type' => [
151
                            'name' => 'Int',
152
                            'kind' => 'SCALAR',
153
                        ],
154
                    ],
155
                    [
156
                        'name' => 'clientMutationId',
157
                        'type' => [
158
                            'name' => 'String',
159
                            'kind' => 'SCALAR',
160
                        ],
161
                    ],
162
163
                ],
164
            ],
165
        ];
166
167
        $this->assertGraphQL($query, $expectedData);
168
    }
169
170
    public function testContainsCorrectField()
171
    {
172
        $query = <<<'EOF'
173
{
174
  __schema {
175
    mutationType {
176
      fields {
177
        name
178
        args {
179
          name
180
          type {
181
            name
182
            kind
183
            ofType {
184
              name
185
              kind
186
            }
187
          }
188
        }
189
        type {
190
          name
191
          kind
192
        }
193
      }
194
    }
195
  }
196
}
197
EOF;
198
199
        $expectedData = [
200
            '__schema' => [
201
                'mutationType' => [
202
                    'fields' => [
203
                        [
204
                            'name' => 'simpleMutation',
205
                            'args' => [
206
                                [
207
                                    'name' => 'input',
208
                                    'type' => [
209
                                        'name' => null,
210
                                        'kind' => 'NON_NULL',
211
                                        'ofType' => [
212
                                            'name' => 'simpleMutationInput',
213
                                            'kind' => 'INPUT_OBJECT',
214
                                        ],
215
                                    ],
216
                                ],
217
                            ],
218
                            'type' => [
219
                                'name' => 'simpleMutationPayload',
220
                                'kind' => 'OBJECT',
221
                            ],
222
                        ],
223
                        [
224
                            'name' => 'simpleMutationWithThunkFields',
225
                            'args' => [
226
                                [
227
                                    'name' => 'input',
228
                                    'type' => [
229
                                        'name' => null,
230
                                        'kind' => 'NON_NULL',
231
                                        'ofType' => [
232
                                            'name' => 'simpleMutationWithThunkFieldsInput',
233
                                            'kind' => 'INPUT_OBJECT',
234
                                        ],
235
                                    ],
236
                                ],
237
                            ],
238
                            'type' => [
239
                                'name' => 'simpleMutationWithThunkFieldsPayload',
240
                                'kind' => 'OBJECT',
241
                            ],
242
                        ],
243
                    ],
244
                ],
245
            ],
246
        ];
247
248
        $this->assertGraphQL($query, $expectedData);
249
    }
250
}
251