‪TYPO3CMS  ‪main
ScopeTest.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 
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
27 final class ‪ScopeTest extends UnitTestCase
28 {
29  protected function ‪tearDown(): void
30  {
31  parent::tearDown();
33  }
34 
38  public function ‪backendSingletonIsCreated(): void
39  {
40  $scope = ‪Scope::backend();
41  self::assertSame($scope, ‪Scope::backend());
42  }
43 
47  public function ‪frontendSingletonIsCreated(): void
48  {
49  $scope = ‪Scope::frontend();
50  self::assertSame($scope, ‪Scope::frontend());
51  }
52 
56  public function ‪frontendSiteIsCreated(): void
57  {
58  $site = new ‪Site('my-site', 1, []);
59  $scope = ‪Scope::frontendSite($site);
60  self::assertSame($scope, ‪Scope::frontendSite($site));
61  }
62 
63  public static function ‪frontendSingletonIsUsedForInvalidSiteDataProvider(): \Generator
64  {
65  yield [null];
66  yield [new ‪NullSite()];
67  }
68 
74  {
75  self::assertSame(‪Scope::frontend(), ‪Scope::frontendSite($site));
76  }
77 
82  {
83  $scope = ‪Scope::frontendSiteIdentifier('my-site');
84  self::assertSame($scope, ‪Scope::frontendSiteIdentifier('my-site'));
85  }
86 
90  public function ‪scopeIsCreatedFromString(): void
91  {
92  self::assertSame(
94  ‪Scope::from(ApplicationType::FRONTEND->value)
95  );
96  self::assertSame(
98  ‪Scope::from(ApplicationType::BACKEND->value)
99  );
100  self::assertSame(
102  ‪Scope::from(ApplicationType::FRONTEND->value . '.my-site')
103  );
104  }
105 }
‪TYPO3\CMS\Core\Site\Entity\SiteInterface
Definition: SiteInterface.php:26
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\backend
‪static backend()
Definition: Scope.php:41
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\frontendSiteIdentifierSingletonIsCreated
‪frontendSiteIdentifierSingletonIsCreated()
Definition: ScopeTest.php:81
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\scopeIsCreatedFromString
‪scopeIsCreatedFromString()
Definition: ScopeTest.php:90
‪TYPO3\CMS\Core\Site\Entity\NullSite
Definition: NullSite.php:32
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\frontendSingletonIsUsedForInvalidSite
‪frontendSingletonIsUsedForInvalidSite(?SiteInterface $site)
Definition: ScopeTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\frontendSingletonIsUsedForInvalidSiteDataProvider
‪static frontendSingletonIsUsedForInvalidSiteDataProvider()
Definition: ScopeTest.php:63
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy
Definition: ConsumableNonceTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\tearDown
‪tearDown()
Definition: ScopeTest.php:29
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:42
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\frontend
‪static frontend()
Definition: Scope.php:46
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\reset
‪static reset()
Definition: Scope.php:83
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope
Definition: Scope.php:30
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\frontendSite
‪static frontendSite(?SiteInterface $site)
Definition: Scope.php:54
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\frontendSiteIdentifier
‪static frontendSiteIdentifier(string $siteIdentifier)
Definition: Scope.php:64
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\frontendSiteIsCreated
‪frontendSiteIsCreated()
Definition: ScopeTest.php:56
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest
Definition: ScopeTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\backendSingletonIsCreated
‪backendSingletonIsCreated()
Definition: ScopeTest.php:38
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope\from
‪static from(string $value)
Definition: Scope.php:69
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:56
‪TYPO3\CMS\Core\Tests\Unit\Security\ContentSecurityPolicy\ScopeTest\frontendSingletonIsCreated
‪frontendSingletonIsCreated()
Definition: ScopeTest.php:47