Code Duplication    Length = 93-93 lines in 2 locations

eZ/Publish/Core/MVC/Symfony/Matcher/Tests/ContentBased/Id/LocationTest.php 1 location

@@ 14-106 (lines=93) @@
11
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
12
use eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\BaseTest;
13
14
class LocationTest extends BaseTest
15
{
16
    /** @var \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location */
17
    private $matcher;
18
19
    protected function setUp(): void
20
    {
21
        parent::setUp();
22
        $this->matcher = new LocationIdMatcher();
23
    }
24
25
    /**
26
     * @dataProvider matchLocationProvider
27
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location::matchLocation
28
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
29
     *
30
     * @param int|int[] $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
                123,
45
                $this->getLocationMock(['id' => 123]),
46
                true,
47
            ],
48
            [
49
                123,
50
                $this->getLocationMock(['id' => 456]),
51
                false,
52
            ],
53
            [
54
                [123, 789],
55
                $this->getLocationMock(['id' => 456]),
56
                false,
57
            ],
58
            [
59
                [123, 789],
60
                $this->getLocationMock(['id' => 789]),
61
                true,
62
            ],
63
        ];
64
    }
65
66
    /**
67
     * @dataProvider matchContentInfoProvider
68
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\Id\Location::matchContentInfo
69
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
70
     *
71
     * @param int|int[] $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
                123,
86
                $this->getContentInfoMock(['mainLocationId' => 123]),
87
                true,
88
            ],
89
            [
90
                123,
91
                $this->getContentInfoMock(['mainLocationId' => 456]),
92
                false,
93
            ],
94
            [
95
                [123, 789],
96
                $this->getContentInfoMock(['mainLocationId' => 456]),
97
                false,
98
            ],
99
            [
100
                [123, 789],
101
                $this->getContentInfoMock(['mainLocationId' => 789]),
102
                true,
103
            ],
104
        ];
105
    }
106
}
107

eZ/Publish/Core/MVC/Symfony/Matcher/Tests/ContentBased/Id/RemoteTest.php 1 location

@@ 14-106 (lines=93) @@
11
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
12
use eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased\BaseTest;
13
14
class RemoteTest extends BaseTest
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