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\SiteAccess\Tests; |
8
|
|
|
|
9
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Router; |
10
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\Host as HostRegexMatcher; |
11
|
|
|
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; |
12
|
|
|
use Psr\Log\LoggerInterface; |
13
|
|
|
|
14
|
|
|
class RouterHostRegexTest extends RouterBaseTest |
15
|
|
|
{ |
16
|
|
View Code Duplication |
public function matchProvider(): array |
17
|
|
|
{ |
18
|
|
|
return [ |
19
|
|
|
[SimplifiedRequest::fromUrl('http://example.com'), 'default_sa'], |
20
|
|
|
[SimplifiedRequest::fromUrl('https://example.com'), 'default_sa'], |
21
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/'), 'default_sa'], |
22
|
|
|
[SimplifiedRequest::fromUrl('https://example.com/'), 'default_sa'], |
23
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//'), 'default_sa'], |
24
|
|
|
[SimplifiedRequest::fromUrl('https://example.com//'), 'default_sa'], |
25
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:8080/'), 'default_sa'], |
26
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_siteaccess/'), 'default_sa'], |
27
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_siteaccess'), 'default_sa'], |
28
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_sa'), 'default_sa'], |
29
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_salt'), 'default_sa'], |
30
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa.foo'), 'default_sa'], |
31
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test'), 'default_sa'], |
32
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/'), 'default_sa'], |
33
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'default_sa'], |
34
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'default_sa'], |
35
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'default_sa'], |
36
|
|
|
|
37
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'first_sa'], |
38
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'first_sa'], |
39
|
|
|
// Double slashes shouldn't be considered as one |
40
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//first_sa//'), 'default_sa'], |
41
|
|
|
[SimplifiedRequest::fromUrl('http://example.com///first_sa///test'), 'default_sa'], |
42
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//first_sa//foo/bar'), 'default_sa'], |
43
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/foo'), 'first_sa'], |
44
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/first_sa/'), 'first_sa'], |
45
|
|
|
[SimplifiedRequest::fromUrl('http://third_siteaccess/first_sa/'), 'first_sa'], |
46
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/'), 'first_sa'], |
47
|
|
|
[SimplifiedRequest::fromUrl('https://first_sa/'), 'first_sa'], |
48
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:81/'), 'first_sa'], |
49
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/'), 'first_sa'], |
50
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:82/'), 'first_sa'], |
51
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:83/'), 'first_sa'], |
52
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/foo/'), 'first_sa'], |
53
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:82/foo/'), 'first_sa'], |
54
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:83/foo/'), 'first_sa'], |
55
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/foobar/'), 'first_sa'], |
56
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa:82/'), 'second_sa'], |
57
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa:83/'), 'second_sa'], |
58
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa/foo/'), 'second_sa'], |
59
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa:82/foo/'), 'second_sa'], |
60
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa:83/foo/'), 'second_sa'], |
61
|
|
|
[SimplifiedRequest::fromUrl('http://second_sa/foobar/'), 'second_sa'], |
62
|
|
|
|
63
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'second_sa'], |
64
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'second_sa'], |
65
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa?param1=foo'), 'second_sa'], |
66
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/foo/'), 'second_sa'], |
67
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/second_sa/'), 'second_sa'], |
68
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:83/second_sa/'), 'second_sa'], |
69
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/second_sa/'), 'second_sa'], |
70
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/second_sa/'), 'second_sa'], |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testGetName() |
75
|
|
|
{ |
76
|
|
|
$matcher = new HostRegexMatcher(['host' => 'foo'], []); |
|
|
|
|
77
|
|
|
$this->assertSame('host:regexp', $matcher->getName()); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Router |
82
|
|
|
*/ |
83
|
|
View Code Duplication |
protected function createRouter(): Router |
84
|
|
|
{ |
85
|
|
|
return new Router( |
86
|
|
|
$this->matcherBuilder, |
87
|
|
|
$this->createMock(LoggerInterface::class), |
88
|
|
|
'default_sa', |
89
|
|
|
[ |
90
|
|
|
'Regex\\Host' => [ |
91
|
|
|
'regex' => '^(\\w+_sa)$', |
92
|
|
|
], |
93
|
|
|
'Map\\URI' => [ |
94
|
|
|
'first_sa' => 'first_sa', |
95
|
|
|
'second_sa' => 'second_sa', |
96
|
|
|
], |
97
|
|
|
'Map\\Host' => [ |
98
|
|
|
'first_sa' => 'first_sa', |
99
|
|
|
'first_siteaccess' => 'first_sa', |
100
|
|
|
], |
101
|
|
|
], |
102
|
|
|
$this->siteAccessProvider |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\SiteAccessSetting[] |
108
|
|
|
*/ |
109
|
|
View Code Duplication |
public function getSiteAccessProviderSettings(): array |
110
|
|
|
{ |
111
|
|
|
return [ |
112
|
|
|
new SiteAccessSetting('first_sa', true), |
113
|
|
|
new SiteAccessSetting('second_sa', true), |
114
|
|
|
new SiteAccessSetting('third_sa', true), |
115
|
|
|
new SiteAccessSetting('fourth_sa', true), |
116
|
|
|
new SiteAccessSetting('fifth_sa', true), |
117
|
|
|
new SiteAccessSetting('example', true), |
118
|
|
|
]; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.