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
Push — master ( 38b593...3478e9 )
by Jérémiah
18:59 queued 16:08
created

DefinitionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
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\Security;
13
14
use GraphQL\Type\Definition\EnumType;
15
use GraphQL\Type\Definition\ObjectType;
16
use GraphQL\Type\Definition\Type;
17
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
18
19
class DefinitionTest extends TestCase
20
{
21
    protected function setUp()
22
    {
23
        parent::setUp();
24
25
        static::createAndBootKernel(['test_case' => 'definition']);
26
    }
27
28
    public function testDefinesEnumTypeWithDeprecatedValue()
29
    {
30
        /** @var EnumType $enumTypeWithDeprecatedValue */
31
        $enumTypeWithDeprecatedValue = $this->getType('EnumWithDeprecatedValue');
32
        $value = $enumTypeWithDeprecatedValue->getValues()[0];
33
        $this->assertEquals([
34
            'name' => 'foo',
35
            'description' => null,
36
            'deprecationReason' => 'Just because',
37
            'value' => 'foo',
38
        ], (array) $value);
39
        $this->assertEquals(true, $this->isDeprecated($value));
40
    }
41
42
    public function testDefinesAnObjectTypeWithDeprecatedField()
43
    {
44
        /** @var ObjectType $TypeWithDeprecatedField */
45
        $TypeWithDeprecatedField = $this->getType('ObjectWithDeprecatedField');
46
        $field = $TypeWithDeprecatedField->getField('bar');
47
        $this->assertEquals(Type::string(), $field->getType());
48
        $this->assertEquals(true, $this->isDeprecated($field));
49
        $this->assertEquals('A terrible reason', $field->deprecationReason);
50
        $this->assertEquals('bar', $field->name);
51
        $this->assertEquals([], $field->args);
52
    }
53
54
    private function isDeprecated($node)
55
    {
56
        // TODO(mcg-web) refactor after moving to latest lib version
57
        if (is_callable([$node, 'isDeprecated'])) {
58
            return $node->isDeprecated();
59
        }
60
61
        return (bool) $node->deprecationReason;
62
    }
63
64
    private function getType($type)
65
    {
66
        return $this->getContainer()->get('overblog_graphql.type_resolver')->resolve($type);
67
    }
68
}
69