‪TYPO3CMS  10.4
ModeRegistryTest.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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ModeRegistryTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
35  protected function ‪setUp(): void
36  {
37  $this->subject = new ‪ModeRegistry();
38  }
39 
43  public function ‪identifierIsReturned(): void
44  {
45  $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/default/default');
46  $this->subject->register($expected);
47  $actual = $this->subject->getByIdentifier('test/mode/default/default');
48 
49  self::assertSame($expected->getIdentifier(), $actual->getIdentifier());
50  }
51 
55  public function ‪latestDefaultModeIsReturned(): void
56  {
57  $firstDefaultMode = GeneralUtility::makeInstance(Mode::class, 'test/another/foo/bar')->setAsDefault();
58  $expected = GeneralUtility::makeInstance(Mode::class, 'test/another/defaultmode/defaultmode')->setAsDefault();
59  $this->subject->register($firstDefaultMode)->register($expected);
60  $actual = $this->subject->getDefaultMode();
61 
62  self::assertSame($expected, $actual);
63  }
64 
68  public function ‪formatCodeReturnsCorrectMode(): void
69  {
70  $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/format/code')->setFormatCode('code');
71  $this->subject->register($expected);
72  $actual = $this->subject->getByFormatCode('code');
73 
74  self::assertSame($expected, $actual);
75  }
76 
80  public function ‪modeIsFetchedByFileExtension(): void
81  {
82  $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/extension/extension')->bindToFileExtensions(['ext', 'fext']);
83  $this->subject->register($expected);
84  $actual = $this->subject->getByFileExtension('fext');
85 
86  self::assertSame($expected, $actual);
87  }
88 }
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\latestDefaultModeIsReturned
‪latestDefaultModeIsReturned()
Definition: ModeRegistryTest.php:54
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\$subject
‪ModeRegistry $subject
Definition: ModeRegistryTest.php:32
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\modeIsFetchedByFileExtension
‪modeIsFetchedByFileExtension()
Definition: ModeRegistryTest.php:79
‪TYPO3\CMS\T3editor\Tests\Unit\Registry
Definition: AddonRegistryTest.php:18
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\setUp
‪setUp()
Definition: ModeRegistryTest.php:34
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest
Definition: ModeRegistryTest.php:29
‪TYPO3\CMS\T3editor\Mode
Definition: Mode.php:25
‪TYPO3\CMS\T3editor\Registry\ModeRegistry
Definition: ModeRegistry.php:30
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\identifierIsReturned
‪identifierIsReturned()
Definition: ModeRegistryTest.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\formatCodeReturnsCorrectMode
‪formatCodeReturnsCorrectMode()
Definition: ModeRegistryTest.php:67