‪TYPO3CMS  ‪main
ResponseFactoryTest.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\ResponseFactoryInterface;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 final class ‪ResponseFactoryTest extends UnitTestCase
29 {
30  #[Test]
31  public function ‪implementsPsr17FactoryInterface(): void
32  {
33  $factory = new ‪ResponseFactory();
34  self::assertInstanceOf(ResponseFactoryInterface::class, $factory);
35  }
36 
37  #[Test]
38  public function ‪responseHasStatusCode200ByDefault(): void
39  {
40  $factory = new ‪ResponseFactory();
41  $response = $factory->createResponse();
42  self::assertSame(200, $response->getStatusCode());
43  }
44 
45  #[Test]
46  public function ‪responseHasStatusCodeSet(): void
47  {
48  $factory = new ‪ResponseFactory();
49  $response = $factory->createResponse(201);
50  self::assertSame(201, $response->getStatusCode());
51  }
52 
53  #[Test]
54  public function ‪responseHasDefaultReasonPhrase(): void
55  {
56  $factory = new ‪ResponseFactory();
57  $response = $factory->createResponse(301);
58  self::assertSame('Moved Permanently', $response->getReasonPhrase());
59  }
60 
61  #[Test]
62  public function ‪responseHasCustomReasonPhrase(): void
63  {
64  $factory = new ‪ResponseFactory();
65  $response = $factory->createResponse(201, 'custom message');
66  self::assertSame('custom message', $response->getReasonPhrase());
67  }
68 }
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest\responseHasDefaultReasonPhrase
‪responseHasDefaultReasonPhrase()
Definition: ResponseFactoryTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Http
Definition: ApplicationTypeTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest\responseHasCustomReasonPhrase
‪responseHasCustomReasonPhrase()
Definition: ResponseFactoryTest.php:62
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest\responseHasStatusCode200ByDefault
‪responseHasStatusCode200ByDefault()
Definition: ResponseFactoryTest.php:38
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest\responseHasStatusCodeSet
‪responseHasStatusCodeSet()
Definition: ResponseFactoryTest.php:46
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest\implementsPsr17FactoryInterface
‪implementsPsr17FactoryInterface()
Definition: ResponseFactoryTest.php:31
‪TYPO3\CMS\Core\Http\ResponseFactory
Definition: ResponseFactory.php:27
‪TYPO3\CMS\Core\Tests\Unit\Http\ResponseFactoryTest
Definition: ResponseFactoryTest.php:29