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