[FOLLOWUP][BUGFIX] EXT:form - themeName can not be overwritten by integrator
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Domain / Model / ConfigurationTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Domain;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\UnitTestCase;
18 use TYPO3\CMS\Form\Domain\Model\Configuration;
19 use TYPO3\CMS\Form\Domain\Repository\TypoScriptRepository;
20
21 /**
22 * Test case for class \TYPO3\CMS\Form\Domain\Model\Configuration
23 */
24 class ConfigurationTest extends UnitTestCase {
25
26 /**
27 * @var Configuration
28 */
29 protected $subject = NULL;
30
31 /*
32 * @var TypoScriptRepository|\Prophecy\Prophecy\ObjectProphecy
33 */
34 protected $typoScriptRepositoryProphecy;
35
36 /**
37 * Sets up this test case.
38 */
39 protected function setUp() {
40 parent::setUp();
41 $this->typoScriptRepositoryProphecy = $this->prophesize(TypoScriptRepository::class);
42 $this->subject = $this->getAccessibleMock(Configuration::class, array('__none'));
43 $this->subject->_set('typoScriptRepository', $this->typoScriptRepositoryProphecy->reveal());
44 }
45
46 /**
47 * Tears down this test case.
48 */
49 protected function tearDown() {
50 parent::tearDown();
51 unset($this->typoScriptRepositoryProphecy);
52 unset($this->subject);
53 }
54
55 /**
56 * @param array $typoScript
57 * @param bool $globalCompatibilityMode
58 * @param string $globalThemeName
59 * @param array $expected
60 *
61 * @test
62 * @dataProvider propertiesAreUpdatedFromTypoScriptDataProvider
63 */
64 public function propertiesAreUpdatedFromTypoScript(array $typoScript, $globalCompatibilityMode, $globalThemeName, array $expected) {
65 $this->typoScriptRepositoryProphecy
66 ->getModelConfigurationByScope('FORM', 'compatibilityMode')
67 ->willReturn($globalCompatibilityMode);
68
69 $this->typoScriptRepositoryProphecy
70 ->getModelConfigurationByScope('FORM', 'themeName')
71 ->willReturn($globalThemeName);
72
73 $this->subject->setTypoScript($typoScript);
74 $this->assertEquals($expected['prefix'], $this->subject->getPrefix());
75 $this->assertEquals($expected['compatibility'], $this->subject->getCompatibility());
76 $this->assertEquals($expected['contentElementRendering'], $this->subject->getContentElementRendering());
77 }
78
79 /**
80 * @return array
81 */
82 public function propertiesAreUpdatedFromTypoScriptDataProvider() {
83 return array(
84 '#1' => array(
85 array(
86 'prefix' => '',
87 'themeName' => '',
88 'compatibilityMode' => FALSE,
89 'disableContentElement' => FALSE,
90 ),
91 FALSE,
92 '',
93 array(
94 'prefix' => 'form',
95 'themeName' => 'Default',
96 'compatibility' => FALSE,
97 'contentElementRendering' => TRUE,
98 ),
99 ),
100 '#2' => array(
101 array(
102 'prefix' => '',
103 'themeName' => '',
104 'compatibilityMode' => FALSE,
105 'disableContentElement' => FALSE,
106 ),
107 TRUE,
108 '',
109 array(
110 'prefix' => 'form',
111 'themeName' => 'Default',
112 'compatibility' => FALSE,
113 'contentElementRendering' => TRUE,
114 ),
115 ),
116 '#3' => array(
117 array(
118 'prefix' => 'somePrefix',
119 'themeName' => 'someTheme',
120 'compatibilityMode' => TRUE,
121 'disableContentElement' => TRUE,
122 ),
123 TRUE,
124 '',
125 array(
126 'prefix' => 'somePrefix',
127 'themeName' => 'someTheme',
128 'compatibility' => TRUE,
129 'contentElementRendering' => FALSE,
130 ),
131 ),
132 '#4' => array(
133 array(
134 'prefix' => 'somePrefix',
135 'themeName' => 'someTheme',
136 'compatibilityMode' => TRUE,
137 'disableContentElement' => TRUE,
138 ),
139 FALSE,
140 '',
141 array(
142 'prefix' => 'somePrefix',
143 'themeName' => 'someTheme',
144 'compatibility' => TRUE,
145 'contentElementRendering' => FALSE,
146 ),
147 ),
148 '#5' => array(
149 array(
150 'prefix' => 'somePrefix',
151 'themeName' => 'someTheme',
152 'compatibilityMode' => NULL,
153 'disableContentElement' => TRUE,
154 ),
155 TRUE,
156 '',
157 array(
158 'prefix' => 'somePrefix',
159 'themeName' => 'someTheme',
160 'compatibility' => TRUE,
161 'contentElementRendering' => FALSE,
162 ),
163 ),
164 '#6' => array(
165 array(
166 'prefix' => 'somePrefix',
167 'themeName' => 'someTheme',
168 'compatibilityMode' => NULL,
169 'disableContentElement' => TRUE,
170 ),
171 FALSE,
172 '',
173 array(
174 'prefix' => 'somePrefix',
175 'themeName' => 'someTheme',
176 'compatibility' => FALSE,
177 'contentElementRendering' => FALSE,
178 ),
179 ),
180 '#7' => array(
181 array(
182 'prefix' => '',
183 'themeName' => '',
184 'compatibilityMode' => FALSE,
185 'disableContentElement' => FALSE,
186 ),
187 FALSE,
188 'globalTheme',
189 array(
190 'prefix' => 'form',
191 'themeName' => 'globalTheme',
192 'compatibility' => FALSE,
193 'contentElementRendering' => TRUE,
194 ),
195 ),
196 );
197 }
198
199 }