‪TYPO3CMS  ‪main
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 PHPUnit\Framework\Attributes\Test;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\ServerRequestInterface;
23 use Psr\Http\Server\RequestHandlerInterface;
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 
30 final class ‪SiteResolverTest extends FunctionalTestCase
31 {
32  #[Test]
34  {
35  $this->expectException(\RuntimeException::class);
36  $this->expectExceptionCode(1668696350);
37  $incomingUrl = 'http://localhost:8080/typo3/module/file/FilelistList?token=d7d864db2b26c1d0f0537718b16890f336f4af2b&id=9831:/styleguide/';
38  $subject = $this->get(SiteResolver::class);
39  $incomingRequest = new ‪ServerRequest($incomingUrl, 'GET');
40  $incomingRequest = $incomingRequest->withQueryParams(['id' => '9831:/styleguide/']);
41  $requestHandler = new class () implements RequestHandlerInterface {
42  public function handle(ServerRequestInterface $request): ResponseInterface
43  {
44  if ($request->getAttribute('site') instanceof ‪NullSite) {
45  throw new \RuntimeException('testing', 1668696350);
46  }
47  return new ‪JsonResponse();
48  }
49  };
50  $subject->process($incomingRequest, $requestHandler);
51  }
52 }
‪TYPO3\CMS\Backend\Tests\Functional\Middleware
Definition: BackendModuleValidatorTest.php:18
‪TYPO3\CMS\Core\Site\Entity\NullSite
Definition: NullSite.php:32
‪TYPO3\CMS\Backend\Tests\Functional\Middleware\SiteResolverTest\requestHasNullSiteAttributeIfIdParameterIsNoInteger
‪requestHasNullSiteAttributeIfIdParameterIsNoInteger()
Definition: SiteResolverTest.php:33
‪TYPO3\CMS\Backend\Tests\Functional\Middleware\SiteResolverTest
Definition: SiteResolverTest.php:31
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:28
‪TYPO3\CMS\Backend\Middleware\SiteResolver
Definition: SiteResolver.php:37