[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / t3editor / Tests / Unit / Registry / ModeRegistryTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\T3editor\Tests\Unit\Registry;
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
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\T3editor\Mode;
20 use TYPO3\CMS\T3editor\Registry\ModeRegistry;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22
23 /**
24 * Unit test class for Registry\ModeRegistry
25 */
26 class ModeRegistryTest extends UnitTestCase
27 {
28 /**
29 * @var ModeRegistry|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
30 */
31 protected $subject;
32
33 protected function setUp()
34 {
35 $this->subject = $this->getAccessibleMock(ModeRegistry::class, ['dummy'], [], '', false);
36 }
37
38 /**
39 * @test
40 */
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
50 /**
51 * @test
52 */
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
63 /**
64 * @test
65 */
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
75 /**
76 * @test
77 */
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 }