‪TYPO3CMS  10.4
SiteResolverTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use Psr\Http\Server\RequestHandlerInterface;
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
28 
29 class ‪SiteResolverTest extends UnitTestCase
30 {
31 
36  {
37  $incomingUrl = 'http://localhost:8080/typo3/index.php?route=/file/FilelistList/&token=d7d864db2b26c1d0f0537718b16890f336f4af2b&id=9831:/styleguide/';
38 
39  $siteMatcherProphecy = $this->prophesize(SiteMatcher::class);
40  $subject = new ‪SiteResolver($siteMatcherProphecy->reveal());
41 
42  $incomingRequest = new ‪ServerRequest($incomingUrl, 'GET');
43  $incomingRequest = $incomingRequest->withQueryParams(['id' => '9831:/styleguide/']);
44  $requestHandler = new class() implements RequestHandlerInterface {
45  public $incomingRequest;
46  public function handle(ServerRequestInterface $request): ResponseInterface
47  {
48  return new ‪JsonResponse([], $request === $this->incomingRequest ? 200 : 500);
49  }
50  public function setIncomingRequest(ServerRequestInterface $incomingRequest)
51  {
52  $this->incomingRequest = $incomingRequest;
53  }
54  };
55  $requestHandler->setIncomingRequest($incomingRequest);
56  $response = $subject->process($incomingRequest, $requestHandler);
57  self::assertEquals(200, $response->getStatusCode());
58  }
59 }
‪TYPO3\CMS\Backend\Tests\Unit\Middleware\SiteResolverTest\RequestIsNotModifiedIfPageIdParameterIsNoInteger
‪RequestIsNotModifiedIfPageIdParameterIsNoInteger()
Definition: SiteResolverTest.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Middleware
Definition: SiteResolverTest.php:18
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:26
‪TYPO3\CMS\Backend\Middleware\SiteResolver
Definition: SiteResolver.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Middleware\SiteResolverTest
Definition: SiteResolverTest.php:30
‪TYPO3\CMS\Core\Routing\SiteMatcher
Definition: SiteMatcher.php:51