| @@ 141-197 (lines=57) @@ | ||
| 138 | $this->assertEquals($expected, $this->router->matchRequest($request)); |
|
| 139 | } |
|
| 140 | ||
| 141 | public function testMatchRequestLocationCaseRedirectWithRootLocation() |
|
| 142 | { |
|
| 143 | $rootLocationId = 123; |
|
| 144 | $this->resetConfigResolver(); |
|
| 145 | $this->configResolver |
|
| 146 | ->expects($this->any()) |
|
| 147 | ->method('getParameter') |
|
| 148 | ->will( |
|
| 149 | $this->returnValueMap( |
|
| 150 | [ |
|
| 151 | ['url_alias_router', null, null, true], |
|
| 152 | ] |
|
| 153 | ) |
|
| 154 | ); |
|
| 155 | $this->router->setRootLocationId($rootLocationId); |
|
| 156 | ||
| 157 | $prefix = '/root/prefix'; |
|
| 158 | $this->urlALiasGenerator |
|
| 159 | ->expects($this->exactly(2)) |
|
| 160 | ->method('getPathPrefixByRootLocationId') |
|
| 161 | ->with($rootLocationId) |
|
| 162 | ->will($this->returnValue($prefix)); |
|
| 163 | $this->urlALiasGenerator |
|
| 164 | ->expects($this->once()) |
|
| 165 | ->method('loadLocation') |
|
| 166 | ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])]))); |
|
| 167 | ||
| 168 | $locationId = 789; |
|
| 169 | $path = '/foo/bar'; |
|
| 170 | $requestedPath = '/Foo/Bar'; |
|
| 171 | $urlAlias = new URLAlias( |
|
| 172 | [ |
|
| 173 | 'destination' => $locationId, |
|
| 174 | 'path' => $prefix . $path, |
|
| 175 | 'type' => URLAlias::LOCATION, |
|
| 176 | 'isHistory' => false, |
|
| 177 | ] |
|
| 178 | ); |
|
| 179 | $this->urlAliasService |
|
| 180 | ->expects($this->once()) |
|
| 181 | ->method('lookup') |
|
| 182 | ->with($prefix . $requestedPath) |
|
| 183 | ->will($this->returnValue($urlAlias)); |
|
| 184 | ||
| 185 | $expected = [ |
|
| 186 | '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
| 187 | '_controller' => UrlAliasRouter::VIEW_ACTION, |
|
| 188 | 'locationId' => $locationId, |
|
| 189 | 'contentId' => 456, |
|
| 190 | 'viewType' => ViewManager::VIEW_TYPE_FULL, |
|
| 191 | 'layout' => true, |
|
| 192 | 'semanticPathinfo' => $path, |
|
| 193 | 'needsRedirect' => true, |
|
| 194 | ]; |
|
| 195 | $request = $this->getRequestByPathInfo($requestedPath); |
|
| 196 | $this->assertEquals($expected, $this->router->matchRequest($request)); |
|
| 197 | } |
|
| 198 | ||
| 199 | public function testMatchRequestLocationCaseRedirectWithRootRootLocation() |
|
| 200 | { |
|
| @@ 199-255 (lines=57) @@ | ||
| 196 | $this->assertEquals($expected, $this->router->matchRequest($request)); |
|
| 197 | } |
|
| 198 | ||
| 199 | public function testMatchRequestLocationCaseRedirectWithRootRootLocation() |
|
| 200 | { |
|
| 201 | $rootLocationId = 123; |
|
| 202 | $this->resetConfigResolver(); |
|
| 203 | $this->configResolver |
|
| 204 | ->expects($this->any()) |
|
| 205 | ->method('getParameter') |
|
| 206 | ->will( |
|
| 207 | $this->returnValueMap( |
|
| 208 | [ |
|
| 209 | ['url_alias_router', null, null, true], |
|
| 210 | ] |
|
| 211 | ) |
|
| 212 | ); |
|
| 213 | $this->router->setRootLocationId($rootLocationId); |
|
| 214 | ||
| 215 | $prefix = '/'; |
|
| 216 | $this->urlALiasGenerator |
|
| 217 | ->expects($this->exactly(2)) |
|
| 218 | ->method('getPathPrefixByRootLocationId') |
|
| 219 | ->with($rootLocationId) |
|
| 220 | ->will($this->returnValue($prefix)); |
|
| 221 | ||
| 222 | $locationId = 789; |
|
| 223 | $path = '/foo/bar'; |
|
| 224 | $requestedPath = '/Foo/Bar'; |
|
| 225 | $urlAlias = new URLAlias( |
|
| 226 | [ |
|
| 227 | 'destination' => $locationId, |
|
| 228 | 'path' => $path, |
|
| 229 | 'type' => URLAlias::LOCATION, |
|
| 230 | 'isHistory' => false, |
|
| 231 | ] |
|
| 232 | ); |
|
| 233 | $this->urlAliasService |
|
| 234 | ->expects($this->once()) |
|
| 235 | ->method('lookup') |
|
| 236 | ->with($requestedPath) |
|
| 237 | ->will($this->returnValue($urlAlias)); |
|
| 238 | $this->urlALiasGenerator |
|
| 239 | ->expects($this->once()) |
|
| 240 | ->method('loadLocation') |
|
| 241 | ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])]))); |
|
| 242 | ||
| 243 | $expected = [ |
|
| 244 | '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
| 245 | '_controller' => UrlAliasRouter::VIEW_ACTION, |
|
| 246 | 'locationId' => $locationId, |
|
| 247 | 'contentId' => 456, |
|
| 248 | 'viewType' => ViewManager::VIEW_TYPE_FULL, |
|
| 249 | 'layout' => true, |
|
| 250 | 'semanticPathinfo' => $path, |
|
| 251 | 'needsRedirect' => true, |
|
| 252 | ]; |
|
| 253 | $request = $this->getRequestByPathInfo($requestedPath); |
|
| 254 | $this->assertEquals($expected, $this->router->matchRequest($request)); |
|
| 255 | } |
|
| 256 | ||
| 257 | public function testMatchRequestResourceCaseRedirectWithRootLocation() |
|
| 258 | { |
|