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