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 (#5)
by Jérémiah
07:11
created

TypeResolverTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 90
Duplicated Lines 30 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
c 1
b 0
f 0
lcom 1
cbo 5
dl 27
loc 90
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A createResolver() 0 4 1
A getResolverSolutionsMapping() 0 7 1
A testResolveKnownType() 0 7 1
A testResolveUnknownType() 0 4 1
A testResolveWithListOfWrapper() 0 8 1
A testResolveWithNonNullWrapper() 0 8 1
A testResolveWithNonNullListOfWrapper() 9 9 1
A testResolveWitListOfNonNullWrapper() 9 9 1
A testResolveWitNonNullListOfNonNullWrapper() 0 10 1
A testResolveWitListOfListOfWrapper() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Resolver;
13
14
use GraphQL\Type\Definition\ObjectType;
15
use Overblog\GraphQLBundle\Resolver\TypeResolver;
16
17
class TypeResolverTest extends AbstractResolverTest
18
{
19
    protected function createResolver()
20
    {
21
        return new TypeResolver();
22
    }
23
24
    protected function getResolverSolutionsMapping()
25
    {
26
        return [
27
            'Toto' => ['solution' => new ObjectType(['name' => 'Toto'])],
28
            'Tata' => ['solution' => new ObjectType(['name' => 'Tata'])],
29
        ];
30
    }
31
32
    public function testResolveKnownType()
33
    {
34
        $type = $this->resolver->resolve('Toto');
35
36
        $this->assertInstanceOf('GraphQL\Type\Definition\ObjectType', $type);
37
        $this->assertEquals('Toto', $type->name);
38
    }
39
40
    /**
41
     * @expectedException \Overblog\GraphQLBundle\Resolver\UnresolvableException
42
     */
43
    public function testResolveUnknownType()
44
    {
45
        $this->resolver->resolve('Fake');
46
    }
47
48
    public function testResolveWithListOfWrapper()
49
    {
50
        /** @var \GraphQL\Type\Definition\WrappingType $type */
51
        $type = $this->resolver->resolve('[Tata]');
52
53
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type);
54
        $this->assertEquals('Tata', $type->getWrappedType());
55
    }
56
57
    public function testResolveWithNonNullWrapper()
58
    {
59
        /** @var \GraphQL\Type\Definition\WrappingType $type */
60
        $type = $this->resolver->resolve('Toto!');
61
62
        $this->assertInstanceOf('GraphQL\Type\Definition\NonNull', $type);
63
        $this->assertEquals('Toto', $type->getWrappedType());
64
    }
65
66 View Code Duplication
    public function testResolveWithNonNullListOfWrapper()
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...
67
    {
68
        /** @var \GraphQL\Type\Definition\WrappingType $type */
69
        $type = $this->resolver->resolve('[Toto]!');
70
71
        $this->assertInstanceOf('GraphQL\Type\Definition\NonNull', $type);
72
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type->getWrappedType());
73
        $this->assertEquals('Toto', $type->getWrappedType()->getWrappedType());
74
    }
75
76 View Code Duplication
    public function testResolveWitListOfNonNullWrapper()
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...
77
    {
78
        /** @var \GraphQL\Type\Definition\WrappingType $type */
79
        $type = $this->resolver->resolve('[Toto!]');
80
81
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type);
82
        $this->assertInstanceOf('GraphQL\Type\Definition\NonNull', $type->getWrappedType());
83
        $this->assertEquals('Toto', $type->getWrappedType()->getWrappedType());
84
    }
85
86
    public function testResolveWitNonNullListOfNonNullWrapper()
87
    {
88
        /** @var \GraphQL\Type\Definition\WrappingType $type */
89
        $type = $this->resolver->resolve('[Toto!]!');
90
91
        $this->assertInstanceOf('GraphQL\Type\Definition\NonNull', $type);
92
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type->getWrappedType());
93
        $this->assertInstanceOf('GraphQL\Type\Definition\NonNull', $type->getWrappedType()->getWrappedType());
94
        $this->assertEquals('Toto', $type->getWrappedType()->getWrappedType()->getWrappedType());
95
    }
96
97 View Code Duplication
    public function testResolveWitListOfListOfWrapper()
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
        /** @var \GraphQL\Type\Definition\WrappingType $type */
100
        $type = $this->resolver->resolve('[[Toto]]');
101
102
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type);
103
        $this->assertInstanceOf('GraphQL\Type\Definition\ListOfType', $type->getWrappedType());
104
        $this->assertEquals('Toto', $type->getWrappedType()->getWrappedType());
105
    }
106
}
107