‪TYPO3CMS  9.5
ModeRegistryTest.php
Go to the documentation of this file.
1 <?php
2 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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪ModeRegistryTest extends UnitTestCase
27 {
31  protected ‪$subject;
32 
33  protected function ‪setUp()
34  {
35  $this->subject = $this->getAccessibleMock(ModeRegistry::class, ['dummy'], [], '', false);
36  }
37 
41  public function ‪identifierIsReturned()
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  static::assertSame($expected->getIdentifier(), $actual->getIdentifier());
48  }
49 
53  public function ‪latestDefaultModeIsReturned()
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  static::assertSame($expected, $actual);
61  }
62 
66  public function ‪formatCodeReturnsCorrectMode()
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  static::assertSame($expected, $actual);
73  }
74 
78  public function ‪modeIsFetchedByFileExtension()
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  static::assertSame($expected, $actual);
85  }
86 }
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\latestDefaultModeIsReturned
‪latestDefaultModeIsReturned()
Definition: ModeRegistryTest.php:52
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\$subject
‪ModeRegistry PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $subject
Definition: ModeRegistryTest.php:30
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\modeIsFetchedByFileExtension
‪modeIsFetchedByFileExtension()
Definition: ModeRegistryTest.php:77
‪TYPO3\CMS\T3editor\Tests\Unit\Registry
Definition: AddonRegistryTest.php:3
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\setUp
‪setUp()
Definition: ModeRegistryTest.php:32
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest
Definition: ModeRegistryTest.php:27
‪TYPO3\CMS\T3editor\Mode
Definition: Mode.php:23
‪TYPO3\CMS\T3editor\Registry\ModeRegistry
Definition: ModeRegistry.php:28
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\identifierIsReturned
‪identifierIsReturned()
Definition: ModeRegistryTest.php:40
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\ModeRegistryTest\formatCodeReturnsCorrectMode
‪formatCodeReturnsCorrectMode()
Definition: ModeRegistryTest.php:65