[TASK] Use name-resolution instead of strings where possible: 3
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Mvc / Controller / ActionControllerTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Controller;
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 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
17 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
18
19 /**
20 * Test case
21 */
22 class ActionControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
26 */
27 protected $actionController;
28
29 /**
30 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
31 */
32 protected $mockObjectManager;
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
36 */
37 protected $mockUriBuilder;
38
39 /**
40 * @var \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService
41 */
42 protected $mockMvcPropertyMappingConfigurationService;
43
44 public function setUp() {
45 $this->actionController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class);
46 }
47
48 /**
49 * @test
50 */
51 public function processRequestSticksToSpecifiedSequence() {
52 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class, array(), array(), '', FALSE);
53 $mockRequest->expects($this->once())->method('setDispatched')->with(TRUE);
54 $mockUriBuilder = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class);
55 $mockUriBuilder->expects($this->once())->method('setRequest')->with($mockRequest);
56 $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
57 $mockObjectManager->expects($this->once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder::class)->will($this->returnValue($mockUriBuilder));
58 $mockResponse = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class, array(), array(), '', FALSE);
59 $configurationService = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class);
60 /** @var \TYPO3\CMS\Extbase\Mvc\Controller\ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
61 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array(
62 'initializeFooAction',
63 'initializeAction',
64 'resolveActionMethodName',
65 'initializeActionMethodArguments',
66 'initializeActionMethodValidators',
67 'mapRequestArgumentsToControllerArguments',
68 'buildControllerContext',
69 'resolveView',
70 'initializeView',
71 'callActionMethod',
72 'checkRequestHash'
73 ), array(), '', FALSE);
74 $mockController->_set('objectManager', $mockObjectManager);
75
76 $mockController->expects($this->at(0))->method('resolveActionMethodName')->will($this->returnValue('fooAction'));
77 $mockController->expects($this->at(1))->method('initializeActionMethodArguments');
78 $mockController->expects($this->at(2))->method('initializeActionMethodValidators');
79 $mockController->expects($this->at(3))->method('initializeAction');
80 $mockController->expects($this->at(4))->method('initializeFooAction');
81 $mockController->expects($this->at(5))->method('mapRequestArgumentsToControllerArguments');
82 $mockController->expects($this->at(6))->method('checkRequestHash');
83 $mockController->expects($this->at(7))->method('buildControllerContext');
84 $mockController->expects($this->at(8))->method('resolveView');
85
86 $mockController->_set('mvcPropertyMappingConfigurationService', $configurationService);
87 $mockController->_set('arguments', new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments());
88
89 $mockController->processRequest($mockRequest, $mockResponse);
90 $this->assertSame($mockRequest, $mockController->_get('request'));
91 $this->assertSame($mockResponse, $mockController->_get('response'));
92 }
93
94 /**
95 * @test
96 * @author Karsten Dambekalns <karsten@typo3.org>
97 */
98 public function resolveViewUsesFluidTemplateViewIfTemplateIsAvailable() {
99 $mockSession = $this->getMock('Tx_Extbase_Session_SessionInterface');
100 $mockControllerContext = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext::class, array(), array(), '', FALSE);
101 $mockFluidTemplateView = $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class);
102 $mockFluidTemplateView->expects($this->once())->method('setControllerContext')->with($mockControllerContext);
103 $mockFluidTemplateView->expects($this->once())->method('canRender')->with($mockControllerContext)->will($this->returnValue(TRUE));
104 $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, array(), array(), '', FALSE);
105 $mockObjectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\View\TemplateView::class)->will($this->returnValue($mockFluidTemplateView));
106 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('buildControllerContext', 'resolveViewObjectName', 'setViewConfiguration'), array(), '', FALSE);
107 $mockController->expects($this->once())->method('resolveViewObjectName')->will($this->returnValue(FALSE));
108 $mockController->_set('session', $mockSession);
109 $mockController->_set('objectManager', $mockObjectManager);
110 $mockController->_set('controllerContext', $mockControllerContext);
111 $this->assertSame($mockFluidTemplateView, $mockController->_call('resolveView'));
112 }
113
114 /**
115 * @test
116 * @author Bastian Waidelich <bastian@typo3.org>
117 */
118 public function resolveViewObjectNameUsesViewObjectNamePatternToResolveViewObjectName() {
119 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
120 $mockRequest->expects($this->once())->method('getControllerVendorName')->will($this->returnValue('MyVendor'));
121 $mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('MyPackage'));
122 $mockRequest->expects($this->once())->method('getControllerName')->will($this->returnValue('MyController'));
123 $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('MyAction'));
124 $mockRequest->expects($this->atLeastOnce())->method('getFormat')->will($this->returnValue('MyFormat'));
125 $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, array(), array(), '', FALSE);
126 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('dummy'), array(), '', FALSE);
127 $mockController->_set('request', $mockRequest);
128 $mockController->_set('objectManager', $mockObjectManager);
129 $mockController->_set('namespacesViewObjectNamePattern', 'RandomViewObject@vendor\@extension\View\@controller\@action@format');
130 $mockController->_call('resolveViewObjectName');
131 }
132
133 /**
134 * @test
135 */
136 public function resolveViewObjectNameUsesNamespacedViewObjectNamePatternForExtensionsWithVendor() {
137 eval('namespace MyVendor\MyPackage\View\MyController; class MyActionMyFormat {}');
138
139 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
140 $mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('MyPackage'));
141 $mockRequest->expects($this->once())->method('getControllerName')->will($this->returnValue('MyController'));
142 $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('MyAction'));
143 $mockRequest->expects($this->once())->method('getControllerVendorName')->will($this->returnValue('MyVendor'));
144 $mockRequest->expects($this->atLeastOnce())->method('getFormat')->will($this->returnValue('MyFormat'));
145 $mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, array(), array(), '', FALSE);
146 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('dummy'), array(), '', FALSE);
147 $mockController->_set('request', $mockRequest);
148 $mockController->_set('objectManager', $mockObjectManager);
149
150 $this->assertEquals(
151 'MyVendor\MyPackage\View\MyController\MyActionMyFormat',
152 $mockController->_call('resolveViewObjectName')
153 );
154 }
155
156 /**
157 * @test
158 * @author Robert Lemke <robert@typo3.org>
159 */
160 public function resolveActionMethodNameReturnsTheCurrentActionMethodNameFromTheRequest() {
161 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
162 $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('fooBar'));
163 /** @var \TYPO3\CMS\Extbase\Mvc\Controller\ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
164 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('fooBarAction'), array(), '', FALSE);
165 $mockController->_set('request', $mockRequest);
166 $this->assertEquals('fooBarAction', $mockController->_call('resolveActionMethodName'));
167 }
168
169 /**
170 * @test
171 * @expectedException \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchActionException
172 * @author Robert Lemke <robert@typo3.org>
173 */
174 public function resolveActionMethodNameThrowsAnExceptionIfTheActionDefinedInTheRequestDoesNotExist() {
175 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
176 $mockRequest->expects($this->once())->method('getControllerActionName')->will($this->returnValue('fooBar'));
177 /** @var \TYPO3\CMS\Extbase\Mvc\Controller\ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
178 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('otherBarAction'), array(), '', FALSE);
179 $mockController->_set('request', $mockRequest);
180 $mockController->_call('resolveActionMethodName');
181 }
182
183 /**
184 * @test
185 * @author Robert Lemke <robert@typo3.org>
186 */
187 public function initializeActionMethodArgumentsRegistersArgumentsFoundInTheSignatureOfTheCurrentActionMethod() {
188 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
189 $mockArguments = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, array('addNewArgument', 'removeAll'));
190 $mockArguments->expects($this->at(0))->method('addNewArgument')->with('stringArgument', 'string', TRUE);
191 $mockArguments->expects($this->at(1))->method('addNewArgument')->with('integerArgument', 'integer', TRUE);
192 $mockArguments->expects($this->at(2))->method('addNewArgument')->with('objectArgument', 'F3_Foo_Bar', TRUE);
193 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('fooAction', 'evaluateDontValidateAnnotations'), array(), '', FALSE);
194 $methodParameters = array(
195 'stringArgument' => array(
196 'position' => 0,
197 'byReference' => FALSE,
198 'array' => FALSE,
199 'optional' => FALSE,
200 'allowsNull' => FALSE,
201 'type' => 'string'
202 ),
203 'integerArgument' => array(
204 'position' => 1,
205 'byReference' => FALSE,
206 'array' => FALSE,
207 'optional' => FALSE,
208 'allowsNull' => FALSE,
209 'type' => 'integer'
210 ),
211 'objectArgument' => array(
212 'position' => 2,
213 'byReference' => FALSE,
214 'array' => FALSE,
215 'optional' => FALSE,
216 'allowsNull' => FALSE,
217 'type' => 'F3_Foo_Bar'
218 )
219 );
220 $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, array(), array(), '', FALSE);
221 $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
222 $mockController->_set('reflectionService', $mockReflectionService);
223 $mockController->_set('request', $mockRequest);
224 $mockController->_set('arguments', $mockArguments);
225 $mockController->_set('actionMethodName', 'fooAction');
226 $mockController->_call('initializeActionMethodArguments');
227 }
228
229 /**
230 * @test
231 * @author Robert Lemke <robert@typo3.org>
232 */
233 public function initializeActionMethodArgumentsRegistersOptionalArgumentsAsSuch() {
234 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
235 $mockArguments = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, array(), array(), '', FALSE);
236 $mockArguments->expects($this->at(0))->method('addNewArgument')->with('arg1', 'string', TRUE);
237 $mockArguments->expects($this->at(1))->method('addNewArgument')->with('arg2', 'array', FALSE, array(21));
238 $mockArguments->expects($this->at(2))->method('addNewArgument')->with('arg3', 'string', FALSE, 42);
239 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('fooAction', 'evaluateDontValidateAnnotations'), array(), '', FALSE);
240 $methodParameters = array(
241 'arg1' => array(
242 'position' => 0,
243 'byReference' => FALSE,
244 'array' => FALSE,
245 'optional' => FALSE,
246 'allowsNull' => FALSE,
247 'type' => 'string'
248 ),
249 'arg2' => array(
250 'position' => 1,
251 'byReference' => FALSE,
252 'array' => TRUE,
253 'optional' => TRUE,
254 'defaultValue' => array(21),
255 'allowsNull' => FALSE
256 ),
257 'arg3' => array(
258 'position' => 2,
259 'byReference' => FALSE,
260 'array' => FALSE,
261 'optional' => TRUE,
262 'defaultValue' => 42,
263 'allowsNull' => FALSE,
264 'type' => 'string'
265 )
266 );
267 $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, array(), array(), '', FALSE);
268 $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
269 $mockController->_set('reflectionService', $mockReflectionService);
270 $mockController->_set('request', $mockRequest);
271 $mockController->_set('arguments', $mockArguments);
272 $mockController->_set('actionMethodName', 'fooAction');
273 $mockController->_call('initializeActionMethodArguments');
274 }
275
276 /**
277 * @test
278 * @author Sebastian Kurf├╝rst <sbastian@typo3.org>
279 * @expectedException \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException
280 */
281 public function initializeActionMethodArgumentsThrowsExceptionIfDataTypeWasNotSpecified() {
282 $mockRequest = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array(), array(), '', FALSE);
283 $mockArguments = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, array(), array(), '', FALSE);
284 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('fooAction'), array(), '', FALSE);
285 $methodParameters = array(
286 'arg1' => array(
287 'position' => 0,
288 'byReference' => FALSE,
289 'array' => FALSE,
290 'optional' => FALSE,
291 'allowsNull' => FALSE
292 )
293 );
294 $mockReflectionService = $this->getMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, array(), array(), '', FALSE);
295 $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
296 $mockController->_set('reflectionService', $mockReflectionService);
297 $mockController->_set('request', $mockRequest);
298 $mockController->_set('arguments', $mockArguments);
299 $mockController->_set('actionMethodName', 'fooAction');
300 $mockController->_call('initializeActionMethodArguments');
301 }
302
303 /**
304 * @test
305 * @dataProvider templateRootPathDataProvider
306 * @param array $configuration
307 * @param array $expected
308 */
309 public function setViewConfigurationResolvesTemplateRootPathsForTemplateRootPath($configuration, $expected) {
310 /** @var ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $mockController */
311 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('dummy'), array(), '', FALSE);
312 /** @var ConfigurationManagerInterface|\PHPUnit_Framework_MockObject_MockObject $mockConfigurationManager */
313 $mockConfigurationManager = $this->getMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
314 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
315 $mockController->injectConfigurationManager($mockConfigurationManager);
316 $mockController->_set('request', $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class), array('getControllerExtensionKey'));
317 $view = $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class, array('setControllerContext', 'assign', 'assignMultiple', 'canRender', 'render', 'initializeView', 'setTemplateRootPaths'));
318 $view->expects($this->once())->method('setTemplateRootPaths')->with($expected);
319 $mockController->_call('setViewConfiguration', $view);
320 }
321
322 /**
323 * @return array
324 */
325 public function templateRootPathDataProvider() {
326 return array(
327 'text keys' => array(
328 array(
329 'view' => array(
330 'templateRootPaths' => array(
331 'default' => 'some path',
332 'extended' => 'some other path'
333 )
334 )
335 ),
336 array(
337 'extended' => 'some other path',
338 'default' => 'some path'
339 )
340 ),
341 'numerical keys' => array(
342 array(
343 'view' => array(
344 'templateRootPaths' => array(
345 '10' => 'some path',
346 '20' => 'some other path',
347 '15' => 'intermediate specific path'
348 )
349 )
350 ),
351 array(
352 '20' => 'some other path',
353 '15' => 'intermediate specific path',
354 '10' => 'some path'
355 )
356 ),
357 'mixed keys' => array(
358 array(
359 'view' => array(
360 'templateRootPaths' => array(
361 '10' => 'some path',
362 'very_specific' => 'some other path',
363 '15' => 'intermediate specific path'
364 )
365 )
366 ),
367 array(
368 '15' => 'intermediate specific path',
369 'very_specific' => 'some other path',
370 '10' => 'some path'
371 )
372 ),
373 );
374 }
375
376 /**
377 * @test
378 * @dataProvider layoutRootPathDataProvider
379 *
380 * @param array $configuration
381 * @param array $expected
382 */
383 public function setViewConfigurationResolvesLayoutRootPathsForLayoutRootPath($configuration, $expected) {
384 /** @var ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $mockController */
385 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('dummy'), array(), '', FALSE);
386 /** @var ConfigurationManagerInterface|\PHPUnit_Framework_MockObject_MockObject $mockConfigurationManager */
387 $mockConfigurationManager = $this->getMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
388 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
389 $mockController->injectConfigurationManager($mockConfigurationManager);
390 $mockController->_set('request', $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class), array('getControllerExtensionKey'));
391 $view = $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class, array('setControllerContext', 'assign', 'assignMultiple', 'canRender', 'render', 'initializeView', 'setlayoutRootPaths'));
392 $view->expects($this->once())->method('setlayoutRootPaths')->with($expected);
393 $mockController->_call('setViewConfiguration', $view);
394 }
395
396 /**
397 * @return array
398 */
399 public function layoutRootPathDataProvider() {
400 return array(
401 'text keys' => array(
402 array(
403 'view' => array(
404 'layoutRootPaths' => array(
405 'default' => 'some path',
406 'extended' => 'some other path'
407 )
408 )
409 ),
410 array(
411 'extended' => 'some other path',
412 'default' => 'some path'
413 )
414 ),
415 'numerical keys' => array(
416 array(
417 'view' => array(
418 'layoutRootPaths' => array(
419 '10' => 'some path',
420 '20' => 'some other path',
421 '15' => 'intermediate specific path'
422 )
423 )
424 ),
425 array(
426 '20' => 'some other path',
427 '15' => 'intermediate specific path',
428 '10' => 'some path'
429 )
430 ),
431 'mixed keys' => array(
432 array(
433 'view' => array(
434 'layoutRootPaths' => array(
435 '10' => 'some path',
436 'very_specific' => 'some other path',
437 '15' => 'intermediate specific path'
438 )
439 )
440 ),
441 array(
442 '15' => 'intermediate specific path',
443 'very_specific' => 'some other path',
444 '10' => 'some path'
445 )
446 ),
447 );
448 }
449
450 /**
451 * @test
452 * @dataProvider partialRootPathDataProvider
453 *
454 * @param array $configuration
455 * @param array $expected
456 */
457 public function setViewConfigurationResolvesPartialRootPathsForPartialRootPath($configuration, $expected) {
458 /** @var ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $mockController */
459 $mockController = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController::class, array('dummy'), array(), '', FALSE);
460 /** @var ConfigurationManagerInterface|\PHPUnit_Framework_MockObject_MockObject $mockConfigurationManager */
461 $mockConfigurationManager = $this->getMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
462 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
463 $mockController->injectConfigurationManager($mockConfigurationManager);
464 $mockController->_set('request', $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class), array('getControllerExtensionKey'));
465 $view = $this->getMock(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class, array('setControllerContext', 'assign', 'assignMultiple', 'canRender', 'render', 'initializeView', 'setpartialRootPaths'));
466 $view->expects($this->once())->method('setpartialRootPaths')->with($expected);
467 $mockController->_call('setViewConfiguration', $view);
468 }
469
470 /**
471 * @return array
472 */
473 public function partialRootPathDataProvider() {
474 return array(
475 'text keys' => array(
476 array(
477 'view' => array(
478 'partialRootPaths' => array(
479 'default' => 'some path',
480 'extended' => 'some other path'
481 )
482 )
483 ),
484 array(
485 'extended' => 'some other path',
486 'default' => 'some path'
487 )
488 ),
489 'numerical keys' => array(
490 array(
491 'view' => array(
492 'partialRootPaths' => array(
493 '10' => 'some path',
494 '20' => 'some other path',
495 '15' => 'intermediate specific path'
496 )
497 )
498 ),
499 array(
500 '20' => 'some other path',
501 '15' => 'intermediate specific path',
502 '10' => 'some path'
503 )
504 ),
505 'mixed keys' => array(
506 array(
507 'view' => array(
508 'partialRootPaths' => array(
509 '10' => 'some path',
510 'very_specific' => 'some other path',
511 '15' => 'intermediate specific path'
512 )
513 )
514 ),
515 array(
516 '15' => 'intermediate specific path',
517 'very_specific' => 'some other path',
518 '10' => 'some path'
519 )
520 ),
521 );
522 }
523 }