‪TYPO3CMS  ‪main
ApplicationTypeTest.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;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
26 final class ‪ApplicationTypeTest extends UnitTestCase
27 {
28  #[Test]
29  public function ‪fromRequestThrowsIfTypeIsMissing(): void
30  {
31  $this->expectException(\RuntimeException::class);
32  $this->expectExceptionCode(1606222812);
34  }
35 
36  #[Test]
37  public function ‪isFrontendReturnsTrueIfFrontend(): void
38  {
39  self::assertTrue(
41  ->isFrontend()
42  );
43  }
44 
45  #[Test]
47  {
48  self::assertFalse(
50  ->isFrontend()
51  );
52  }
53 
54  #[Test]
55  public function ‪isBackendReturnsTrueIfBackend(): void
56  {
57  self::assertTrue(
59  ->isBackend()
60  );
61  }
62 
63  #[Test]
64  public function ‪isBackendReturnsTrueIfNotBackend(): void
65  {
66  self::assertFalse(
68  ->isBackend()
69  );
70  }
71 
72  #[Test]
73  public function ‪isFrontendEnumResolved(): void
74  {
75  $type = ApplicationType::FRONTEND;
76  self::assertSame('frontend', $type->value);
77  self::assertSame('FE', $type->abbreviate());
78  }
79 
80  #[Test]
81  public function ‪isBackendEnumResolved(): void
82  {
83  $type = ApplicationType::BACKEND;
84  self::assertSame('backend', $type->value);
85  self::assertSame('BE', $type->abbreviate());
86  }
87 }
‪TYPO3\CMS\Core\Tests\Unit\Http
Definition: ApplicationTypeTest.php:18
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfNotBackend
‪isBackendReturnsTrueIfNotBackend()
Definition: ApplicationTypeTest.php:64
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsFalseIfNotFrontend
‪isFrontendReturnsFalseIfNotFrontend()
Definition: ApplicationTypeTest.php:46
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendEnumResolved
‪isBackendEnumResolved()
Definition: ApplicationTypeTest.php:81
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest
Definition: ApplicationTypeTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\fromRequestThrowsIfTypeIsMissing
‪fromRequestThrowsIfTypeIsMissing()
Definition: ApplicationTypeTest.php:29
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendEnumResolved
‪isFrontendEnumResolved()
Definition: ApplicationTypeTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isBackendReturnsTrueIfBackend
‪isBackendReturnsTrueIfBackend()
Definition: ApplicationTypeTest.php:55
‪TYPO3\CMS\Core\Tests\Unit\Http\ApplicationTypeTest\isFrontendReturnsTrueIfFrontend
‪isFrontendReturnsTrueIfFrontend()
Definition: ApplicationTypeTest.php:37
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:66
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:55