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 (#240)
by Renato
25:10
created

ResolverTaggedServiceMappingPassTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 43.48 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 30
loc 69
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A addCompilerPassesAndCompile() 0 6 1
A testCompilationWorksPassConfigDirective() 0 14 1
A testTagAliasIsValid() 15 15 1
A testTagMethodIsValid() 15 15 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
namespace Overblog\GraphQLBundle\Tests\DependencyInjection\Compiler;
4
5
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverTaggedServiceMappingPass;
6
use Overblog\GraphQLBundle\Resolver\ResolverResolver;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Definition;
10
11
class ResolverTaggedServiceMappingPassTest extends TestCase
12
{
13
    /** @var ContainerBuilder */
14
    private $container;
15
16
    public function setUp()
17
    {
18
        $container = new ContainerBuilder();
19
        $container->setDefinition('injected_service', new Definition(FakeInjectedService::class));
20
21
        $container->register('overblog_graphql.resolver_resolver', ResolverResolver::class);
22
23
        $this->container = $container;
24
    }
25
26
    private function addCompilerPassesAndCompile()
27
    {
28
        $this->container->addCompilerPass(new ResolverTaggedServiceMappingPass());
29
        $this->container->addCompilerPass(new FakeCompilerPass());
30
        $this->container->compile();
31
    }
32
33
    public function testCompilationWorksPassConfigDirective()
34
    {
35
        $testResolver = new Definition(ResolverTestService::class);
36
        $testResolver
37
            ->addTag('overblog_graphql.resolver', [
38
                'alias' => 'test_resolver', 'method' => 'doSomethingWithContainer',
39
            ]);
40
41
        $this->container->setDefinition('test_resolver', $testResolver);
42
43
        $this->addCompilerPassesAndCompile();
44
45
        $this->assertTrue($this->container->has('test_resolver'));
46
    }
47
48 View Code Duplication
    public function testTagAliasIsValid()
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
        $testResolver = new Definition(ResolverTestService::class);
51
        $testResolver
52
            ->addTag('overblog_graphql.resolver', [
53
                'alias' => false, 'method' => 'doSomethingWithContainer',
54
            ]);
55
56
        $this->container->setDefinition('test_resolver', $testResolver);
57
58
        $this->expectException(\InvalidArgumentException::class);
59
        $this->expectExceptionMessage('Service tagged "test_resolver" must have valid "alias" argument.');
60
61
        $this->addCompilerPassesAndCompile();
62
    }
63
64 View Code Duplication
    public function testTagMethodIsValid()
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...
65
    {
66
        $testResolver = new Definition(ResolverTestService::class);
67
        $testResolver
68
            ->addTag('overblog_graphql.resolver', [
69
                'alias' => 'test_resolver', 'method' => false,
70
            ]);
71
72
        $this->container->setDefinition('test_resolver', $testResolver);
73
74
        $this->expectException(\InvalidArgumentException::class);
75
        $this->expectExceptionMessage('Service tagged "test_resolver" must have valid "method" argument.');
76
77
        $this->addCompilerPassesAndCompile();
78
    }
79
}
80