Completed
Push — master ( 90226b...85c5a1 )
by
unknown
19:31
created

setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the ContentBasedMatcherFactoryTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\MVC\Symfony\Matcher\Tests;
10
11
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver;
12
use eZ\Publish\Core\MVC\Symfony\Matcher\ClassNameMatcherFactory;
13
use eZ\Publish\Core\MVC\Symfony\Matcher\DynamicallyConfiguredMatcherFactoryDecorator;
14
use eZ\Publish\Core\MVC\Symfony\View\ContentView;
15
use PHPUnit\Framework\TestCase;
16
17
class DynamicallyConfiguredMatcherFactoryDecoratorTest extends TestCase
18
{
19
    /** @var \eZ\Publish\Core\MVC\Symfony\Matcher\ConfigurableMatcherFactoryInterface */
20
    private $innerMatcherFactory;
21
22
    /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */
23
    private $configResolver;
24
25
    public function setUp(): void
26
    {
27
        $innerMatcherFactory = $this->createMock(ClassNameMatcherFactory::class);
28
        $configResolver = $this->createMock(ConfigResolver::class);
29
30
        $this->innerMatcherFactory = $innerMatcherFactory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $innerMatcherFactory of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<eZ\Publish\Core\M...atcherFactoryInterface> of property $innerMatcherFactory.

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...
31
        $this->configResolver = $configResolver;
0 ignored issues
show
Documentation Bug introduced by
It seems like $configResolver of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<eZ\Publish\Core\M...onfigResolverInterface> of property $configResolver.

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...
32
    }
33
34
    /**
35
     * @dataProvider matchConfigProvider
36
     */
37
    public function testMatch($parameterName, $namespace, $scope, $viewsConfiguration, $matchedConfig): void
38
    {
39
        $view = $this->createMock(ContentView::class);
40
        $this->configResolver->expects($this->atLeastOnce())->method('getParameter')->with($parameterName, $namespace,
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\M...onfigResolverInterface>.

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...
41
            $scope)->willReturn($viewsConfiguration);
42
        $this->innerMatcherFactory->expects($this->once())->method('match')->with($view)->willReturn($matchedConfig);
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\M...atcherFactoryInterface>.

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...
43
44
        $matcherFactory = new DynamicallyConfiguredMatcherFactoryDecorator(
45
            $this->innerMatcherFactory,
46
            $this->configResolver,
47
            $parameterName,
48
            $namespace,
49
            $scope
50
        );
51
52
        $this->assertEquals($matchedConfig, $matcherFactory->match($view));
53
    }
54
55
    public function matchConfigProvider(): array
56
    {
57
        return [
58
            [
59
                'location_view',
60
                null,
61
                null,
62
                [
63
                    'full' => [
64
                        'test' => [
65
                            'template' => 'foo.html.twig',
66
                            'match' => [
67
                                \stdClass::class => true,
68
                            ],
69
                        ],
70
                    ],
71
                ],
72
                [
73
                    'template' => 'foo.html.twig',
74
                    'match' => [
75
                        \stdClass::class => true,
76
                    ],
77
                ],
78
            ],
79
        ];
80
    }
81
}
82