‪TYPO3CMS  11.5
AddonRegistryTest.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 ‪AddonRegistryTest extends UnitTestCase
29 {
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35  $this->subject = new ‪AddonRegistry();
36  $this->‪registerAddons();
37  }
38 
42  protected function ‪registerAddons(): void
43  {
44  $this->subject
45  ->register(GeneralUtility::makeInstance(Addon::class, 'addon/global'))
46  ->register(
47  GeneralUtility::makeInstance(Addon::class, 'addon/another/global')
48  ->setCssFiles(['EXT:foobar/Resources/Public/Css/Addon.css'])
49  )
50  ->register(
51  GeneralUtility::makeInstance(Addon::class, 'addon/with/same/cssfile')
52  ->setOptions([
53  'foobar' => true,
54  'husel' => 'pusel',
55  ])
56  ->setCssFiles(['EXT:foobar/Resources/Public/Css/Addon.css'])
57  )
58  ->register(
59  GeneralUtility::makeInstance(Addon::class, 'addon/for/mode')
60  ->setModes(['xml', 'htmlmixed'])
61  )
62  ->register(
63  GeneralUtility::makeInstance(Addon::class, 'addon/with/settings')
64  ->setOptions([
65  'foobar' => false,
66  'randomInt' => 4, // chosen by fair dice roll
67  ])
68  );
69  }
70 
74  public function ‪globalAddonsGetReturned(): void
75  {
76  $expected = [
77  'addon/global',
78  'addon/another/global',
79  'addon/with/same/cssfile',
80  'addon/with/settings',
81  ];
82 
83  $actual = [];
84  foreach ($this->subject->getForMode() as $addon) {
85  $actual[] = $addon->getIdentifier();
86  }
87 
88  self::assertSame($expected, $actual);
89  }
90 
94  public function ‪globalAndModeAddonsGetReturned(): void
95  {
96  $expected = [
97  'addon/global',
98  'addon/another/global',
99  'addon/with/same/cssfile',
100  'addon/for/mode',
101  'addon/with/settings',
102  ];
103 
104  $actual = [];
105  foreach ($this->subject->getForMode('xml') as $addon) {
106  $actual[] = $addon->getIdentifier();
107  }
108 
109  self::assertSame($expected, $actual);
110  }
111 
115  public function ‪settingsAreProperlyCompiled(): void
116  {
117  $expected = [
118  'foobar' => false,
119  'husel' => 'pusel',
120  'randomInt' => 4,
121  ];
122 
123  $actual = $this->subject->compileSettings($this->subject->getForMode());
124 
125  self::assertSame($expected, $actual);
126  }
127 }
‪TYPO3\CMS\T3editor\Registry\AddonRegistry
Definition: AddonRegistry.php:29
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\globalAddonsGetReturned
‪globalAddonsGetReturned()
Definition: AddonRegistryTest.php:74
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\setUp
‪setUp()
Definition: AddonRegistryTest.php:32
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\$subject
‪AddonRegistry $subject
Definition: AddonRegistryTest.php:30
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\registerAddons
‪registerAddons()
Definition: AddonRegistryTest.php:42
‪TYPO3\CMS\T3editor\Addon
Definition: Addon.php:25
‪TYPO3\CMS\T3editor\Tests\Unit\Registry
Definition: AddonRegistryTest.php:18
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\globalAndModeAddonsGetReturned
‪globalAndModeAddonsGetReturned()
Definition: AddonRegistryTest.php:94
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\settingsAreProperlyCompiled
‪settingsAreProperlyCompiled()
Definition: AddonRegistryTest.php:115
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest
Definition: AddonRegistryTest.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50