1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\RouterURITextTest 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\SiteAccess\Tests; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess; |
12
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Router; |
15
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIText as URITextMatcher; |
16
|
|
|
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; |
17
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\MatcherBuilder; |
18
|
|
|
use Psr\Log\LoggerInterface; |
19
|
|
|
|
20
|
|
|
abstract class RouterBaseTest extends TestCase |
21
|
|
|
{ |
22
|
|
|
/** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess\MatcherBuilder */ |
23
|
|
|
protected $matcherBuilder; |
24
|
|
|
|
25
|
|
|
/** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessProviderInterface */ |
26
|
|
|
protected $siteAccessProvider; |
27
|
|
|
|
28
|
|
|
protected function setUp(): void |
29
|
|
|
{ |
30
|
|
|
parent::setUp(); |
31
|
|
|
$this->matcherBuilder = new MatcherBuilder(); |
32
|
|
|
$this->siteAccessProvider = $this->createSiteAccessProviderMock(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testConstruct(): Router |
36
|
|
|
{ |
37
|
|
|
return $this->createRouter(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @dataProvider matchProvider |
42
|
|
|
*/ |
43
|
|
View Code Duplication |
public function testMatch(SimplifiedRequest $request, string $siteAccess) |
44
|
|
|
{ |
45
|
|
|
$router = $this->createRouter(); |
46
|
|
|
$sa = $router->match($request); |
47
|
|
|
$this->assertInstanceOf(SiteAccess::class, $sa); |
48
|
|
|
$this->assertSame($siteAccess, $sa->name); |
49
|
|
|
$router->setSiteAccess(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
abstract public function matchProvider(): array; |
53
|
|
|
|
54
|
|
|
abstract protected function createRouter(): Router; |
55
|
|
|
|
56
|
|
|
private function createSiteAccessProviderMock(): SiteAccess\SiteAccessProviderInterface |
57
|
|
|
{ |
58
|
|
|
$isDefinedMap = []; |
59
|
|
|
$getSiteAccessMap = []; |
60
|
|
|
foreach ($this->getSiteAccessProviderSettings() as $sa) { |
61
|
|
|
$isDefinedMap[] = [$sa->name, $sa->isDefined]; |
62
|
|
|
$getSiteAccessMap[] = [ |
63
|
|
|
$sa->name, |
64
|
|
|
new SiteAccess( |
65
|
|
|
$sa->name, |
66
|
|
|
$sa->matchingType |
67
|
|
|
) |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
$siteAccessProviderMock = $this->createMock(SiteAccess\SiteAccessProviderInterface::class); |
71
|
|
|
$siteAccessProviderMock |
|
|
|
|
72
|
|
|
->method('isDefined') |
73
|
|
|
->willReturnMap($isDefinedMap); |
74
|
|
|
$siteAccessProviderMock |
|
|
|
|
75
|
|
|
->method('getSiteAccess') |
76
|
|
|
->willReturnMap($getSiteAccessMap); |
77
|
|
|
|
78
|
|
|
return $siteAccessProviderMock; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\SiteAccessSetting[] |
83
|
|
|
*/ |
84
|
|
|
abstract public function getSiteAccessProviderSettings(): array; |
85
|
|
|
} |
86
|
|
|
|
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.