‪TYPO3CMS  11.5
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 Prophecy\PhpUnit\ProphecyTrait;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
23 use Psr\Http\Server\RequestHandlerInterface;
28 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
29 
30 class ‪SiteResolverTest extends UnitTestCase
31 {
32  use ProphecyTrait;
33 
38  {
39  $incomingUrl = 'http://localhost:8080/typo3/module/file/FilelistList?token=d7d864db2b26c1d0f0537718b16890f336f4af2b&id=9831:/styleguide/';
40 
41  $siteMatcherProphecy = $this->prophesize(SiteMatcher::class);
42  $subject = new ‪SiteResolver($siteMatcherProphecy->reveal());
43 
44  $incomingRequest = new ‪ServerRequest($incomingUrl, 'GET');
45  $incomingRequest = $incomingRequest->withQueryParams(['id' => '9831:/styleguide/']);
46  $requestHandler = new class () implements RequestHandlerInterface {
47  public ServerRequestInterface $incomingRequest;
48  public function handle(ServerRequestInterface $request): ResponseInterface
49  {
50  return new ‪JsonResponse([], $request === $this->incomingRequest ? 200 : 500);
51  }
52  public function setIncomingRequest(ServerRequestInterface $incomingRequest): void
53  {
54  $this->incomingRequest = $incomingRequest;
55  }
56  };
57  $requestHandler->setIncomingRequest($incomingRequest);
58  $response = $subject->process($incomingRequest, $requestHandler);
59  self::assertEquals(200, $response->getStatusCode());
60  }
61 }
‪TYPO3\CMS\Backend\Tests\Unit\Middleware\SiteResolverTest\RequestIsNotModifiedIfPageIdParameterIsNoInteger
‪RequestIsNotModifiedIfPageIdParameterIsNoInteger()
Definition: SiteResolverTest.php:36
‪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:28
‪TYPO3\CMS\Backend\Middleware\SiteResolver
Definition: SiteResolver.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Middleware\SiteResolverTest
Definition: SiteResolverTest.php:31
‪TYPO3\CMS\Core\Routing\SiteMatcher
Definition: SiteMatcher.php:52