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.
Test Setup Failed
Push — master ( aeed96...e25155 )
by Malte
03:19
created

ShortcodeCompilerPassTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Webfactory\ShortcodeBundle\Tests\DependencyInjection\Compiler;
4
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Thunder\Shortcode\HandlerContainer\HandlerContainer;
10
use Webfactory\ShortcodeBundle\Controller\GuideController;
11
use Webfactory\ShortcodeBundle\DependencyInjection\Compiler\ShortcodeCompilerPass;
12
13
final class ShortcodeCompilerPassTest extends TestCase
14
{
15
    /**
16
     * System under test.
17
     *
18
     * @var ShortcodeCompilerPass
19
     */
20
    private $compilerPass;
21
22
    /** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject */
23
    private $containerBuilder;
24
25
    protected function setUp(): void
26
    {
27
        $this->compilerPass = new ShortcodeCompilerPass();
28
        $this->containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockBuilder(Sy...onstructor()->getMock() of type PHPUnit\Framework\MockObject\MockObject is incompatible with the declared type PHPUnit_Framework_MockOb...ection\ContainerBuilder of property $containerBuilder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
            ->disableOriginalConstructor()
30
            ->getMock();
31
    }
32
33
    /** @test */
34
    public function tagged_services_are_added_as_handlers_to_handler_container(): void
35
    {
36
        $this->containerBuilder->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not exist on Symfony\Component\Depend...ection\ContainerBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $this->containerBuilder->/** @scrutinizer ignore-call */ 
37
                                 expects($this->once())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            ->method('findTaggedServiceIds')
38
            ->willReturn([
39
                'service_id1' => [
40
                    ['shortcode' => 'shortcode1'],
41
                ],
42
                'service_id2' => [
43
                    ['shortcode' => 'shortcode2'],
44
                ],
45
            ]);
46
47
        $mockedShortcodeHandlerContainer = $this->createMock(Definition::class);
48
        $mockedShortcodeHandlerContainer->expects($this->at(0))
49
            ->method('addMethodCall')
50
            ->with('add', $this->callback(function (array $argument) {
51
                return 'shortcode1' === $argument[0]
52
                    && $argument[1] instanceof Reference;
53
            }));
54
        $mockedShortcodeHandlerContainer->expects($this->at(1))
55
            ->method('addMethodCall')
56
            ->with('add', $this->callback(function ($argument) {
57
                return 'shortcode2' === $argument[0]
58
                    && $argument[1] instanceof Reference;
59
            }));
60
61
        $this->containerBuilder->expects($this->once())
62
            ->method('findDefinition')
63
            ->with(HandlerContainer::class)
64
            ->willReturn($mockedShortcodeHandlerContainer);
65
66
        $this->compilerPass->process($this->containerBuilder);
67
    }
68
69
    /** @test */
70
    public function no_tagged_services_do_no_harm(): void
71
    {
72
        $this->containerBuilder->expects($this->once())
73
            ->method('findTaggedServiceIds')
74
            ->willReturn([]);
75
76
        $this->compilerPass->process($this->containerBuilder);
77
    }
78
79
    /** @test */
80
    public function shortcode_guide_service_gets_configured_if_set(): void
81
    {
82
        $this->containerBuilder->expects($this->once())
83
            ->method('findTaggedServiceIds')
84
            ->willReturn([
85
                'service_id1' => [
86
                    ['shortcode' => 'shortcode1'],
87
                ],
88
                'service_id2' => [
89
                    ['shortcode' => 'shortcode2'],
90
                ],
91
            ]);
92
93
        $this->containerBuilder->expects($this->once())
94
            ->method('findDefinition')
95
            ->with(HandlerContainer::class)
96
            ->willReturn($this->createMock(Definition::class));
97
98
        $this->containerBuilder->expects($this->once())
99
            ->method('has')
100
            ->with(GuideController::class)
101
            ->willReturn(true);
102
103
        $mockedShortcodeGuideServiceDefinition = $this->createMock(Definition::class);
104
        $mockedShortcodeGuideServiceDefinition->expects($this->once())
105
            ->method('setArgument')
106
            ->with(
107
                0,
108
                [
109
                    ['shortcode' => 'shortcode1'],
110
                    ['shortcode' => 'shortcode2'],
111
                ]
112
            );
113
114
        $this->containerBuilder->expects($this->once())
115
            ->method('getDefinition')
116
            ->with(GuideController::class)
117
            ->willReturn($mockedShortcodeGuideServiceDefinition);
118
119
        $this->compilerPass->process($this->containerBuilder);
120
    }
121
122
    /** @test */
123
    public function missing_shortcode_guide_service_does_no_harm(): void
124
    {
125
        $this->containerBuilder->expects($this->once())
126
            ->method('findTaggedServiceIds')
127
            ->willReturn([]);
128
129
        $this->containerBuilder->expects($this->once())
130
            ->method('has')
131
            ->with(GuideController::class)
132
            ->willReturn(false);
133
134
        $this->compilerPass->process($this->containerBuilder);
135
    }
136
}
137