GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( a8069a...4b1aa9 )
by Malte
12:40
created

ShortcodeCompilerPassTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Webfactory\ShortcodeBundle\Tests\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Definition;
7
use Symfony\Component\DependencyInjection\Reference;
8
use Symfony\Component\DependencyInjection\TaggedContainerInterface;
9
use Thunder\Shortcode\ShortcodeFacade;
10
use Webfactory\ShortcodeBundle\DependencyInjection\Compiler\ShortcodeCompilerPass;
11
12
final class ShortcodeCompilerPassTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * System under test.
16
     *
17
     * @var ShortcodeCompilerPass
18
     */
19
    private $compilerPass;
20
21
    /** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject */
22
    private $containerBuilder;
23
24
    protected function setUp()
25
    {
26
        $this->compilerPass = new ShortcodeCompilerPass();
27
        $this->containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
28
            ->disableOriginalConstructor()
29
            ->getMock();
30
    }
31
32
    /** @test */
33
    public function tagged_services_are_added_as_handlers_to_facade()
0 ignored issues
show
Coding Style Naming introduced by
The method tagged_services_are_added_as_handlers_to_facade is not named in camelCase.

This check marks method names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
Method name "ShortcodeCompilerPassTest::tagged_services_are_added_as_handlers_to_facade" is not in camel caps format
Loading history...
34
    {
35
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...ection\ContainerBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
36
            ->method('findTaggedServiceIds')
37
            ->willReturn([
38
                'service_id1' => [
39
                    ['shortcode' => 'shortcode1']
40
                ],
41
                'service_id2' => [
42
                    ['shortcode' => 'shortcode2']
43
                ]
44
            ]);
45
46
        $mockedShortcodeFacade = $this->getMock(Definition::class);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $mockedShortcodeFacade exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
47
        $mockedShortcodeFacade->expects($this->at(0))
48
            ->method('addMethodCall')
49
            ->with('addHandler', $this->callback(function (array $argument) {
50
                return $argument[0] === 'shortcode1'
51
                    && $argument[1] instanceof Reference;
52
            }));
53
        $mockedShortcodeFacade->expects($this->at(1))
54
            ->method('addMethodCall')
55
            ->with('addHandler', $this->callback(function ($argument) {
56
                return $argument[0] === 'shortcode2'
57
                    && $argument[1] instanceof Reference;
58
            }));
59
60
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...ection\ContainerBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
61
            ->method('findDefinition')
62
            ->with('webfactory.shortcode.facade')
63
            ->willReturn($mockedShortcodeFacade);
64
65
        $this->compilerPass->process($this->containerBuilder);
66
    }
67
68
    /** @test */
69
    public function no_tagged_services_do_no_harm()
0 ignored issues
show
Coding Style Naming introduced by
The method no_tagged_services_do_no_harm is not named in camelCase.

This check marks method names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
Method name "ShortcodeCompilerPassTest::no_tagged_services_do_no_harm" is not in camel caps format
Loading history...
70
    {
71
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...ection\ContainerBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
72
            ->method('findTaggedServiceIds')
73
            ->willReturn([]);
74
75
        $this->setExpectedException(null);
76
77
        $this->compilerPass->process($this->containerBuilder);
78
    }
79
80
    /** @test */
81
    public function shortcode_guide_service_gets_configured_if_set()
0 ignored issues
show
Coding Style Naming introduced by
The method shortcode_guide_service_gets_configured_if_set is not named in camelCase.

This check marks method names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
Method name "ShortcodeCompilerPassTest::shortcode_guide_service_gets_configured_if_set" is not in camel caps format
Loading history...
82
    {
83
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...ection\ContainerBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
84
            ->method('findTaggedServiceIds')
85
            ->willReturn([
86
                'service_id1' => [
87
                    ['shortcode' => 'shortcode1']
88
                ],
89
                'service_id2' => [
90
                    ['shortcode' => 'shortcode2']
91
                ]
92
            ]);
93
94
        $this->containerBuilder->expects($this->once())
95
            ->method('findDefinition')
96
            ->with('webfactory.shortcode.facade')
97
            ->willReturn($this->getMock(Definition::class));
98
99
        $this->containerBuilder->expects($this->once())
100
            ->method('has')
101
            ->with('webfactory.shortcode.guide.controller')
102
            ->willReturn(true);
103
104
        $mockedShortcodeGuideServiceDefinition = $this->getMock(Definition::class);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $mockedShortcodeGuideServiceDefinition exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
105
        $mockedShortcodeGuideServiceDefinition->expects($this->once())
106
            ->method('setArgument')
107
            ->with(
108
                0,
109
                [
110
                    ['shortcode' => 'shortcode1'],
111
                    ['shortcode' => 'shortcode2']
112
                ]
113
            );
114
115
        $this->containerBuilder->expects($this->once())
116
            ->method('getDefinition')
117
            ->with('webfactory.shortcode.guide.controller')
118
            ->willReturn($mockedShortcodeGuideServiceDefinition);
119
120
        $this->compilerPass->process($this->containerBuilder);
121
    }
122
123
    /** @test */
124
    public function missing_shortcode_guide_service_does_no_harm()
0 ignored issues
show
Coding Style Naming introduced by
The method missing_shortcode_guide_service_does_no_harm is not named in camelCase.

This check marks method names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
Method name "ShortcodeCompilerPassTest::missing_shortcode_guide_service_does_no_harm" is not in camel caps format
Loading history...
125
    {
126
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Symfony\Component\Depend...ection\ContainerBuilder.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
127
            ->method('findTaggedServiceIds')
128
            ->willReturn([]);
129
130
        $this->containerBuilder->expects($this->once())
131
            ->method('has')
132
            ->with('webfactory.shortcode.guide.controller')
133
            ->willReturn(false);
134
135
        $this->setExpectedException(null);
136
137
        $this->compilerPass->process($this->containerBuilder);
138
    }
139
}
140