Completed
Push — master ( ff8f52...ed8581 )
by
unknown
12:31 queued 10s
created

RemoteTest::testMatchLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 5
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\Id;
8
9
use eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote as RemoteIdMatcher;
10
use eZ\Publish\API\Repository\Values\Content\Location;
11
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
12
use eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\BaseTest;
13
14 View Code Duplication
class RemoteTest extends BaseTest
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    /** @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote */
17
    private $matcher;
18
19
    protected function setUp(): void
20
    {
21
        parent::setUp();
22
        $this->matcher = new RemoteIdMatcher();
23
    }
24
25
    /**
26
     * @dataProvider matchLocationProvider
27
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote::matchLocation
28
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
29
     *
30
     * @param string|string[] $matchingConfig
31
     * @param \eZ\Publish\API\Repository\Values\Content\Location $location
32
     * @param bool $expectedResult
33
     */
34
    public function testMatchLocation($matchingConfig, Location $location, $expectedResult)
35
    {
36
        $this->matcher->setMatchingConfig($matchingConfig);
37
        $this->assertSame($expectedResult, $this->matcher->matchLocation($location));
38
    }
39
40
    public function matchLocationProvider()
41
    {
42
        return [
43
            [
44
                'foo',
45
                $this->getLocationMock(['remoteId' => 'foo']),
46
                true,
47
            ],
48
            [
49
                'foo',
50
                $this->getLocationMock(['remoteId' => 'bar']),
51
                false,
52
            ],
53
            [
54
                ['foo', 'baz'],
55
                $this->getLocationMock(['remoteId' => 'bar']),
56
                false,
57
            ],
58
            [
59
                ['foo', 'baz'],
60
                $this->getLocationMock(['remoteId' => 'baz']),
61
                true,
62
            ],
63
        ];
64
    }
65
66
    /**
67
     * @dataProvider matchContentInfoProvider
68
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Remote::matchContentInfo
69
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
70
     *
71
     * @param string|string[] $matchingConfig
72
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
73
     * @param bool $expectedResult
74
     */
75
    public function testMatchContentInfo($matchingConfig, ContentInfo $contentInfo, $expectedResult)
76
    {
77
        $this->matcher->setMatchingConfig($matchingConfig);
78
        $this->assertSame($expectedResult, $this->matcher->matchContentInfo($contentInfo));
79
    }
80
81
    public function matchContentInfoProvider()
82
    {
83
        return [
84
            [
85
                'foo',
86
                $this->getContentInfoMock(['remoteId' => 'foo']),
87
                true,
88
            ],
89
            [
90
                'foo',
91
                $this->getContentInfoMock(['remoteId' => 'bar']),
92
                false,
93
            ],
94
            [
95
                ['foo', 'baz'],
96
                $this->getContentInfoMock(['remoteId' => 'bar']),
97
                false,
98
            ],
99
            [
100
                ['foo', 'baz'],
101
                $this->getContentInfoMock(['remoteId' => 'baz']),
102
                true,
103
            ],
104
        ];
105
    }
106
}
107