1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\RouterURIRegexTest 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 PHPUnit\Framework\TestCase; |
13
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Router; |
14
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\URI as RegexMatcher; |
15
|
|
|
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; |
16
|
|
|
use eZ\Publish\Core\MVC\Symfony\SiteAccess\MatcherBuilder; |
17
|
|
|
use Psr\Log\LoggerInterface; |
18
|
|
|
|
19
|
|
|
class RouterURIRegexTest extends RouterBaseTest |
20
|
|
|
{ |
21
|
|
View Code Duplication |
public function matchProvider(): array |
22
|
|
|
{ |
23
|
|
|
return [ |
24
|
|
|
[SimplifiedRequest::fromUrl('http://example.com'), 'default_sa'], |
25
|
|
|
[SimplifiedRequest::fromUrl('https://example.com'), 'default_sa'], |
26
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/'), 'default_sa'], |
27
|
|
|
[SimplifiedRequest::fromUrl('https://example.com/'), 'default_sa'], |
28
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//'), 'default_sa'], |
29
|
|
|
[SimplifiedRequest::fromUrl('https://example.com//'), 'default_sa'], |
30
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:8080/'), 'default_sa'], |
31
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_siteaccess/'), 'default_sa'], |
32
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_siteaccess'), 'default_sa'], |
33
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/?first_sa'), 'default_sa'], |
34
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_salt'), 'default_sa'], |
35
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa.foo'), 'default_sa'], |
36
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test'), 'default_sa'], |
37
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/'), 'default_sa'], |
38
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/'), 'default_sa'], |
39
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/test/foo/bar/first_sa'), 'default_sa'], |
40
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/default_sa'), 'default_sa'], |
41
|
|
|
|
42
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa'), 'first_sa'], |
43
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/'), 'first_sa'], |
44
|
|
|
// Double slashes shouldn't be considered as one |
45
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//first_sa//'), 'default_sa'], |
46
|
|
|
[SimplifiedRequest::fromUrl('http://example.com///first_sa///test'), 'default_sa'], |
47
|
|
|
[SimplifiedRequest::fromUrl('http://example.com//first_sa//foo/bar'), 'default_sa'], |
48
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/first_sa/foo'), 'first_sa'], |
49
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/first_sa/'), 'first_sa'], |
50
|
|
|
[SimplifiedRequest::fromUrl('http://third_siteaccess/first_sa/'), 'first_sa'], |
51
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa/'), 'first_sa'], |
52
|
|
|
[SimplifiedRequest::fromUrl('https://first_sa/'), 'first_sa'], |
53
|
|
|
[SimplifiedRequest::fromUrl('http://first_sa:81/'), 'first_sa'], |
54
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/'), 'first_sa'], |
55
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/'), 'first_sa'], |
56
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/'), 'first_sa'], |
57
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/foo/'), 'first_sa'], |
58
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/foo/'), 'first_sa'], |
59
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/foo/'), 'first_sa'], |
60
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/foobar/'), 'first_sa'], |
61
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess//foobar/'), 'first_sa'], |
62
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess//footestbar/'), 'first_sa'], |
63
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/footestbar/'), 'test'], |
64
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess/footestbar/foobazbar/'), 'test'], |
65
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/footestbar/'), 'test'], |
66
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/footestbar/'), 'test'], |
67
|
|
|
|
68
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa'), 'second_sa'], |
69
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/'), 'second_sa'], |
70
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa?param1=foo'), 'second_sa'], |
71
|
|
|
[SimplifiedRequest::fromUrl('http://example.com/second_sa/foo/'), 'second_sa'], |
72
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:82/second_sa/'), 'second_sa'], |
73
|
|
|
[SimplifiedRequest::fromUrl('http://example.com:83/second_sa/'), 'second_sa'], |
74
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:82/second_sa/'), 'second_sa'], |
75
|
|
|
[SimplifiedRequest::fromUrl('http://first_siteaccess:83/second_sa/'), 'second_sa'], |
76
|
|
|
]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testGetName() |
80
|
|
|
{ |
81
|
|
|
$matcher = new RegexMatcher([], []); |
|
|
|
|
82
|
|
|
$this->assertSame('uri:regexp', $matcher->getName()); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
View Code Duplication |
public function testSerialize() |
86
|
|
|
{ |
87
|
|
|
$matcher = new RegexMatcher( |
|
|
|
|
88
|
|
|
[ |
89
|
|
|
'regex' => '^/foo(\\w+)bar', |
90
|
|
|
'itemNumber' => 2, |
91
|
|
|
] |
92
|
|
|
); |
93
|
|
|
$matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); |
94
|
|
|
$sa = new SiteAccess('test', 'test', $matcher); |
95
|
|
|
$serializedSA1 = serialize($sa); |
96
|
|
|
|
97
|
|
|
$matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); |
98
|
|
|
$serializedSA2 = serialize($sa); |
99
|
|
|
|
100
|
|
|
$this->assertSame($serializedSA1, $serializedSA2); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
View Code Duplication |
protected function createRouter(): Router |
104
|
|
|
{ |
105
|
|
|
return new Router( |
106
|
|
|
$this->matcherBuilder, |
107
|
|
|
$this->createMock(LoggerInterface::class), |
108
|
|
|
'default_sa', |
109
|
|
|
[ |
110
|
|
|
'Regex\\URI' => [ |
111
|
|
|
'regex' => '^/foo(\\w+)bar', |
112
|
|
|
], |
113
|
|
|
'Map\\URI' => [ |
114
|
|
|
'first_sa' => 'first_sa', |
115
|
|
|
'second_sa' => 'second_sa', |
116
|
|
|
], |
117
|
|
|
'Map\\Host' => [ |
118
|
|
|
'first_sa' => 'first_sa', |
119
|
|
|
'first_siteaccess' => 'first_sa', |
120
|
|
|
], |
121
|
|
|
], |
122
|
|
|
$this->siteAccessProvider |
123
|
|
|
); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return \eZ\Publish\Core\MVC\Symfony\SiteAccess\Tests\SiteAccessSetting[] |
128
|
|
|
*/ |
129
|
|
View Code Duplication |
public function getSiteAccessProviderSettings(): array |
130
|
|
|
{ |
131
|
|
|
return [ |
132
|
|
|
new SiteAccessSetting('first_sa', true), |
133
|
|
|
new SiteAccessSetting('second_sa', true), |
134
|
|
|
new SiteAccessSetting('third_sa', true), |
135
|
|
|
new SiteAccessSetting('fourth_sa', true), |
136
|
|
|
new SiteAccessSetting('fifth_sa', true), |
137
|
|
|
new SiteAccessSetting('test', true), |
138
|
|
|
]; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
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.