[BUGFIX] storagePid is lost when persistence.recursive is set
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Configuration / AbstractConfigurationManagerTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Configuration;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * All rights reserved
8 *
9 * This class is a backport of the corresponding class of TYPO3 Flow.
10 * All credits go to the TYPO3 Flow team.
11 *
12 * This script is part of the TYPO3 project. The TYPO3 project is
13 * free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * The GNU General Public License can be found at
19 * http://www.gnu.org/copyleft/gpl.html.
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 class AbstractConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
29
30 /**
31 * @var \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
32 */
33 protected $abstractConfigurationManager;
34
35 /**
36 * @var \TYPO3\CMS\Extbase\Service\TypoScriptService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
37 */
38 protected $mockTypoScriptService;
39
40 /**
41 * @var array
42 */
43 protected $testTypoScriptSetup = array(
44 'foo.' => array(
45 'bar' => 'baz'
46 ),
47 'config.' => array(
48 'tx_extbase.' => array(
49 'settings.' => array(
50 'setting1' => 'value1',
51 'setting2' => 'value2'
52 ),
53 'view.' => array(
54 'viewSub.' => array(
55 'key1' => 'value1',
56 'key2' => 'value2'
57 )
58 )
59 )
60 )
61 );
62
63 /**
64 * @var array
65 */
66 protected $testTypoScriptSetupConverted = array(
67 'foo' => array(
68 'bar' => 'baz'
69 ),
70 'config' => array(
71 'tx_extbase' => array(
72 'settings' => array(
73 'setting1' => 'value1',
74 'setting2' => 'value2'
75 ),
76 'view' => array(
77 'viewSub' => array(
78 'key1' => 'value1',
79 'key2' => 'value2'
80 )
81 )
82 )
83 )
84 );
85
86 /**
87 * @var array
88 */
89 protected $testPluginConfiguration = array(
90 'settings' => array(
91 'setting1' => 'overriddenValue1',
92 'setting3' => 'additionalValue'
93 ),
94 'view' => array(
95 'viewSub' => array(
96 'key1' => 'overridden',
97 'key3' => 'new key'
98 )
99 ),
100 'persistence' => array(
101 'storagePid' => '123'
102 )
103 );
104
105 /**
106 * @var array
107 */
108 protected $testSwitchableControllerActions = array(
109 'Controller1' => array(
110 'actions' => array('action1', 'action2', 'action3')
111 ),
112 'Controller2' => array(
113 'actions' => array('action4', 'action5', 'action6'),
114 'nonCacheableActions' => array('action4', 'action6')
115 )
116 );
117
118 /**
119 * Sets up this testcase
120 */
121 public function setUp() {
122 $this->abstractConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\AbstractConfigurationManager', array('getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions', 'getRecursiveStoragePids'));
123 $this->mockTypoScriptService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
124 $this->abstractConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
125 }
126
127 /**
128 * @test
129 */
130 public function setConfigurationResetsConfigurationCache() {
131 $this->abstractConfigurationManager->_set('configurationCache', array('foo' => 'bar'));
132 $this->abstractConfigurationManager->setConfiguration(array());
133 $this->assertEquals(array(), $this->abstractConfigurationManager->_get('configurationCache'));
134 }
135
136 /**
137 * @test
138 */
139 public function setConfigurationSetsExtensionAndPluginName() {
140 $configuration = array(
141 'extensionName' => 'SomeExtensionName',
142 'pluginName' => 'SomePluginName'
143 );
144 $this->abstractConfigurationManager->setConfiguration($configuration);
145 $this->assertEquals('SomeExtensionName', $this->abstractConfigurationManager->_get('extensionName'));
146 $this->assertEquals('SomePluginName', $this->abstractConfigurationManager->_get('pluginName'));
147 }
148
149 /**
150 * @test
151 */
152 public function setConfigurationConvertsTypoScriptArrayToPlainArray() {
153 $configuration = array(
154 'foo' => 'bar',
155 'settings.' => array('foo' => 'bar'),
156 'view.' => array('subkey.' => array('subsubkey' => 'subsubvalue'))
157 );
158 $expectedResult = array(
159 'foo' => 'bar',
160 'settings' => array('foo' => 'bar'),
161 'view' => array('subkey' => array('subsubkey' => 'subsubvalue'))
162 );
163 $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($expectedResult));
164 $this->abstractConfigurationManager->setConfiguration($configuration);
165 $this->assertEquals($expectedResult, $this->abstractConfigurationManager->_get('configuration'));
166 }
167
168 /**
169 * @test
170 */
171 public function getConfigurationReturnsCachedResultOfCurrentPlugin() {
172 $this->abstractConfigurationManager->_set('extensionName', 'CurrentExtensionName');
173 $this->abstractConfigurationManager->_set('pluginName', 'CurrentPluginName');
174 $this->abstractConfigurationManager->_set('configurationCache', array('currentextensionname_currentpluginname' => array('foo' => 'bar'), 'someotherextension_somepluginname' => array('baz' => 'shouldnotbereturned')));
175 $expectedResult = array('foo' => 'bar');
176 $actualResult = $this->abstractConfigurationManager->getConfiguration();
177 $this->assertEquals($expectedResult, $actualResult);
178 }
179
180 /**
181 * @test
182 */
183 public function getConfigurationReturnsCachedResultForGivenExtension() {
184 $this->abstractConfigurationManager->_set('configurationCache', array('someextensionname_somepluginname' => array('foo' => 'bar'), 'someotherextension_somepluginname' => array('baz' => 'shouldnotbereturned')));
185 $expectedResult = array('foo' => 'bar');
186 $actualResult = $this->abstractConfigurationManager->getConfiguration('SomeExtensionName', 'SomePluginName');
187 $this->assertEquals($expectedResult, $actualResult);
188 }
189
190 /**
191 * @test
192 */
193 public function getConfigurationRecursivelyMergesCurrentPluginConfigurationWithFrameworkConfiguration() {
194 $this->abstractConfigurationManager->_set('extensionName', 'CurrentExtensionName');
195 $this->abstractConfigurationManager->_set('pluginName', 'CurrentPluginName');
196 $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
197 $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted['config']['tx_extbase']));
198 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
199 $expectedResult = array(
200 'settings' => array(
201 'setting1' => 'overriddenValue1',
202 'setting2' => 'value2',
203 'setting3' => 'additionalValue'
204 ),
205 'view' => array(
206 'viewSub' => array(
207 'key1' => 'overridden',
208 'key2' => 'value2',
209 'key3' => 'new key'
210 )
211 ),
212 'persistence' => array(
213 'storagePid' => '123'
214 ),
215 'controllerConfiguration' => NULL
216 );
217 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->with($expectedResult)->will($this->returnValue($expectedResult));
218 $actualResult = $this->abstractConfigurationManager->getConfiguration();
219 $this->assertEquals($expectedResult, $actualResult);
220 }
221
222 /**
223 * @test
224 */
225 public function getConfigurationRecursivelyMergesPluginConfigurationOfSpecifiedPluginWithFrameworkConfiguration() {
226 $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
227 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('SomeExtensionName', 'SomePluginName')->will($this->returnValue($this->testPluginConfiguration));
228 $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted['config']['tx_extbase']));
229 $expectedResult = array(
230 'settings' => array(
231 'setting1' => 'overriddenValue1',
232 'setting2' => 'value2',
233 'setting3' => 'additionalValue'
234 ),
235 'view' => array(
236 'viewSub' => array(
237 'key1' => 'overridden',
238 'key2' => 'value2',
239 'key3' => 'new key'
240 )
241 ),
242 'persistence' => array(
243 'storagePid' => '123'
244 ),
245 'controllerConfiguration' => NULL
246 );
247 $this->abstractConfigurationManager->expects($this->never())->method('getContextSpecificFrameworkConfiguration');
248 $actualResult = $this->abstractConfigurationManager->getConfiguration('SomeExtensionName', 'SomePluginName');
249 $this->assertEquals($expectedResult, $actualResult);
250 }
251
252 /**
253 * @test
254 */
255 public function getConfigurationDoesNotOverrideConfigurationWithContextSpecificFrameworkConfigurationIfDifferentPluginIsSpecified() {
256 $this->abstractConfigurationManager->expects($this->never())->method('getContextSpecificFrameworkConfiguration');
257 $this->abstractConfigurationManager->getConfiguration('SomeExtensionName', 'SomePluginName');
258 }
259
260 /**
261 * @test
262 */
263 public function getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfNoPluginWasSpecified() {
264 $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
265 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with()->will($this->returnValue($this->testPluginConfiguration));
266 $contextSpecifixFrameworkConfiguration = array(
267 'context' => array(
268 'specific' => 'framwork',
269 'conf' => 'iguration'
270 )
271 );
272 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnValue($contextSpecifixFrameworkConfiguration));
273 $actualResult = $this->abstractConfigurationManager->getConfiguration();
274 $this->assertEquals($contextSpecifixFrameworkConfiguration, $actualResult);
275 }
276
277 /**
278 * @test
279 */
280 public function getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfSpecifiedPluginIsTheCurrentPlugin() {
281 $this->abstractConfigurationManager->_set('extensionName', 'CurrentExtensionName');
282 $this->abstractConfigurationManager->_set('pluginName', 'CurrentPluginName');
283 $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
284 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
285 $contextSpecifixFrameworkConfiguration = array(
286 'context' => array(
287 'specific' => 'framwork',
288 'conf' => 'iguration'
289 )
290 );
291 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnValue($contextSpecifixFrameworkConfiguration));
292 $actualResult = $this->abstractConfigurationManager->getConfiguration('CurrentExtensionName', 'CurrentPluginName');
293 $this->assertEquals($contextSpecifixFrameworkConfiguration, $actualResult);
294 }
295
296 /**
297 * @test
298 */
299 public function getConfigurationStoresResultInConfigurationCache() {
300 $this->abstractConfigurationManager->_set('extensionName', 'CurrentExtensionName');
301 $this->abstractConfigurationManager->_set('pluginName', 'CurrentPluginName');
302 $this->abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array('foo' => 'bar')));
303 $this->abstractConfigurationManager->getConfiguration();
304 $this->abstractConfigurationManager->getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
305 $expectedResult = array('currentextensionname_currentpluginname', 'someotherextensionname_someothercurrentpluginname');
306 $actualResult = array_keys($this->abstractConfigurationManager->_get('configurationCache'));
307 $this->assertEquals($expectedResult, $actualResult);
308 }
309
310 /**
311 * @test
312 */
313 public function getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForSingleStoragePid() {
314 $pluginConfiguration = array(
315 'persistence' => array(
316 'storagePid' => 1,
317 'recursive' => 99
318 )
319 );
320 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->will($this->returnValue($pluginConfiguration));
321 $this->abstractConfigurationManager->expects($this->once())->method('getRecursiveStoragePids')->with('-1');
322 $this->abstractConfigurationManager->getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
323 }
324
325 /**
326 * @test
327 */
328 public function getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForMultipleStoragePid() {
329 $pluginConfiguration = array(
330 'persistence' => array(
331 'storagePid' => '1,25',
332 'recursive' => 99
333 )
334 );
335 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->will($this->returnValue($pluginConfiguration));
336 $this->abstractConfigurationManager->expects($this->once())->method('getRecursiveStoragePids')->with('-1,-25');
337 $this->abstractConfigurationManager->getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
338 }
339
340 /**
341 * switchableControllerActions *
342 */
343 /**
344 * @test
345 */
346 public function switchableControllerActionsAreNotOverriddenIfPluginNameIsSpecified() {
347 /** @var \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
348 $abstractConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions', 'getRecursiveStoragePids'));
349 $abstractConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
350 $abstractConfigurationManager->setConfiguration(array('switchableControllerActions' => array('overriddenSwitchableControllerActions')));
351 $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
352 $abstractConfigurationManager->expects($this->never())->method('overrideSwitchableControllerActions');
353 $abstractConfigurationManager->getConfiguration('SomeExtensionName', 'SomePluginName');
354 }
355
356 /**
357 * @test
358 */
359 public function switchableControllerActionsAreOverriddenIfSpecifiedPluginIsTheCurrentPlugin() {
360 /** @var \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
361 $configuration = array('extensionName' => 'CurrentExtensionName', 'pluginName' => 'CurrentPluginName', 'switchableControllerActions' => array('overriddenSwitchableControllerActions'));
362 $abstractConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions', 'getRecursiveStoragePids'));
363 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
364 $abstractConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
365 $abstractConfigurationManager->setConfiguration($configuration);
366 $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
367 $abstractConfigurationManager->expects($this->once())->method('overrideSwitchableControllerActions');
368 $abstractConfigurationManager->getConfiguration('CurrentExtensionName', 'CurrentPluginName');
369 }
370
371 /**
372 * @test
373 */
374 public function switchableControllerActionsAreOverriddenIfPluginNameIsNotSpecified() {
375 /** @var \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
376 $configuration = array('switchableControllerActions' => array('overriddenSwitchableControllerActions'));
377 $abstractConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions', 'getRecursiveStoragePids'));
378 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
379 $abstractConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
380 $abstractConfigurationManager->setConfiguration($configuration);
381 $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
382 $abstractConfigurationManager->expects($this->once())->method('overrideSwitchableControllerActions');
383 $abstractConfigurationManager->getConfiguration();
384 }
385
386 /**
387 * @test
388 */
389 public function orderOfActionsCanBeOverriddenForCurrentPlugin() {
390 $configuration = array(
391 'extensionName' => 'CurrentExtensionName',
392 'pluginName' => 'CurrentPluginName',
393 'switchableControllerActions' => array(
394 'Controller1' => array('action2', 'action1', 'action3')
395 )
396 );
397 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
398 $this->abstractConfigurationManager->setConfiguration($configuration);
399 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
400 $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
401 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnCallBack(create_function('$a', 'return $a;')));
402 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
403 $expectedResult = array(
404 'Controller1' => array(
405 'actions' => array('action2', 'action1', 'action3')
406 )
407 );
408 $actualResult = $mergedConfiguration['controllerConfiguration'];
409 $this->assertEquals($expectedResult, $actualResult);
410 }
411
412 /**
413 * @test
414 */
415 public function newActionsCanBeAddedForCurrentPlugin() {
416 $configuration = array(
417 'extensionName' => 'CurrentExtensionName',
418 'pluginName' => 'CurrentPluginName',
419 'switchableControllerActions' => array(
420 'Controller1' => array('action2', 'action1', 'action3', 'newAction')
421 )
422 );
423 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
424 $this->abstractConfigurationManager->setConfiguration($configuration);
425 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
426 $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
427 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnCallBack(create_function('$a', 'return $a;')));
428 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
429 $expectedResult = array(
430 'Controller1' => array(
431 'actions' => array('action2', 'action1', 'action3', 'newAction')
432 )
433 );
434 $actualResult = $mergedConfiguration['controllerConfiguration'];
435 $this->assertEquals($expectedResult, $actualResult);
436 }
437
438 /**
439 * @test
440 */
441 public function controllersCanNotBeOverridden() {
442 $configuration = array(
443 'extensionName' => 'CurrentExtensionName',
444 'pluginName' => 'CurrentPluginName',
445 'switchableControllerActions' => array(
446 'NewController' => array('action1', 'action2')
447 )
448 );
449 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
450 $this->abstractConfigurationManager->setConfiguration($configuration);
451 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
452 $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
453 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnCallBack(create_function('$a', 'return $a;')));
454 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
455 $expectedResult = array();
456 $actualResult = $mergedConfiguration['controllerConfiguration'];
457 $this->assertEquals($expectedResult, $actualResult);
458 }
459
460 /**
461 * @test
462 */
463 public function cachingOfActionsCanNotBeChanged() {
464 $configuration = array(
465 'extensionName' => 'CurrentExtensionName',
466 'pluginName' => 'CurrentPluginName',
467 'switchableControllerActions' => array(
468 'Controller1' => array('newAction', 'action1'),
469 'Controller2' => array('newAction2', 'action4', 'action5')
470 )
471 );
472 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
473 $this->abstractConfigurationManager->setConfiguration($configuration);
474 $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
475 $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
476 $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnCallBack(create_function('$a', 'return $a;')));
477 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
478 $expectedResult = array(
479 'Controller1' => array(
480 'actions' => array('newAction', 'action1')
481 ),
482 'Controller2' => array(
483 'actions' => array('newAction2', 'action4', 'action5'),
484 'nonCacheableActions' => array('action4')
485 )
486 );
487 $actualResult = $mergedConfiguration['controllerConfiguration'];
488 $this->assertEquals($expectedResult, $actualResult);
489 }
490
491 /**
492 * @test
493 */
494 public function getContentObjectReturnsNullIfNoContentObjectHasBeenSet() {
495 $this->assertNull($this->abstractConfigurationManager->getContentObject());
496 }
497
498 /**
499 * @test
500 */
501 public function getContentObjectTheCurrentContentObject() {
502 $mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
503 $this->abstractConfigurationManager->setContentObject($mockContentObject);
504 $this->assertSame($this->abstractConfigurationManager->getContentObject(), $mockContentObject);
505 }
506 }
507
508 ?>