Completed
Push — ezp-30882-thumbnail ( 274ed9...d4335b )
by
unknown
14:43
created

SiteAccessMatcherRegistryTest::testGetMatcher()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
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
declare(strict_types=1);
8
9
namespace eZ\Bundle\EzPublishCoreBundle\SiteAccess;
10
11
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
12
use PHPUnit\Framework\TestCase;
13
14
class SiteAccessMatcherRegistryTest extends TestCase
15
{
16
    private const MATCHER_NAME = 'test_matcher';
17
18
    public function testGetMatcher(): void
19
    {
20
        $matcher = $this->getMatcherMock();
21
        $registry = new SiteAccessMatcherRegistry([self::MATCHER_NAME => $matcher]);
22
23
        $this->assertSame($matcher, $registry->getMatcher(self::MATCHER_NAME));
24
    }
25
26
    public function testSetMatcher(): void
27
    {
28
        $matcher = $this->getMatcherMock();
29
        $registry = new SiteAccessMatcherRegistry();
30
31
        $registry->setMatcher(self::MATCHER_NAME, $matcher);
32
33
        $this->assertSame($matcher, $registry->getMatcher(self::MATCHER_NAME));
34
    }
35
36
    public function testSetMatcherOverride(): void
37
    {
38
        $matcher = $this->getMatcherMock();
39
        $newMatcher = $this->getMatcherMock();
40
        $registry = new SiteAccessMatcherRegistry([self::MATCHER_NAME, $matcher]);
41
42
        $registry->setMatcher(self::MATCHER_NAME, $newMatcher);
43
44
        $this->assertSame($newMatcher, $registry->getMatcher(self::MATCHER_NAME));
45
    }
46
47
    public function testGetMatcherNotFound(): void
48
    {
49
        $this->expectException(NotFoundException::class);
50
        $registry = new SiteAccessMatcherRegistry();
51
52
        $registry->getMatcher(self::MATCHER_NAME);
53
    }
54
55
    protected function getMatcherMock(): Matcher
56
    {
57
        return $this->createMock(Matcher::class);
58
    }
59
}
60