‪TYPO3CMS  9.5
AddonRegistryTest.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 ‪AddonRegistryTest extends UnitTestCase
27 {
31  protected ‪$subject;
32 
33  protected function ‪setUp()
34  {
35  $this->subject = $this->getAccessibleMock(AddonRegistry::class, ['dummy'], [], '', false);
36  $this->‪registerAddons();
37  }
38 
42  protected function ‪registerAddons()
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  }
71 
75  public function ‪globalAddonsGetReturned()
76  {
77  $expected = [
78  'addon/global',
79  'addon/another/global',
80  'addon/with/same/cssfile',
81  'addon/with/settings',
82  ];
83 
84  $actual = [];
85  foreach ($this->subject->getForMode() as $addon) {
86  $actual[] = $addon->getIdentifier();
87  }
88 
89  static::assertSame($expected, $actual);
90  }
91 
95  public function ‪globalAndModeAddonsGetReturned()
96  {
97  $expected = [
98  'addon/global',
99  'addon/another/global',
100  'addon/with/same/cssfile',
101  'addon/for/mode',
102  'addon/with/settings',
103  ];
104 
105  $actual = [];
106  foreach ($this->subject->getForMode('xml') as $addon) {
107  $actual[] = $addon->getIdentifier();
108  }
109 
110  static::assertSame($expected, $actual);
111  }
112 
116  public function ‪settingsAreProperlyCompiled()
117  {
118  $expected = [
119  'foobar' => false,
120  'husel' => 'pusel',
121  'randomInt' => 4
122  ];
123 
124  $actual = $this->subject->compileSettings($this->subject->getForMode());
125 
126  static::assertSame($expected, $actual);
127  }
128 }
‪TYPO3\CMS\T3editor\Registry\AddonRegistry
Definition: AddonRegistry.php:27
‪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\registerAddons
‪registerAddons()
Definition: AddonRegistryTest.php:41
‪TYPO3\CMS\T3editor\Addon
Definition: Addon.php:23
‪TYPO3\CMS\T3editor\Tests\Unit\Registry
Definition: AddonRegistryTest.php:3
‪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:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\T3editor\Tests\Unit\Registry\AddonRegistryTest\$subject
‪AddonRegistry PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $subject
Definition: AddonRegistryTest.php:30