43 $this->actionController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController');
49 public function processRequestSticksToSpecifiedSequence() {
50 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array(), array(),
'', FALSE);
51 $mockRequest->expects($this->once())->method(
'setDispatched')->with(TRUE);
52 $mockUriBuilder = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
53 $mockUriBuilder->expects($this->once())->method(
'setRequest')->with($mockRequest);
54 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
56 $mockResponse = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response', array(), array(),
'', FALSE);
57 $configurationService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\MvcPropertyMappingConfigurationService');
59 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
60 'initializeFooAction',
62 'resolveActionMethodName',
63 'initializeActionMethodArguments',
64 'initializeActionMethodValidators',
65 'mapRequestArgumentsToControllerArguments',
66 'buildControllerContext',
71 ), array(),
'', FALSE);
74 $mockController->expects($this->at(0))->method(
'resolveActionMethodName')->will($this->returnValue(
'fooAction'));
75 $mockController->expects($this->at(1))->method(
'initializeActionMethodArguments');
76 $mockController->expects($this->at(2))->method(
'initializeActionMethodValidators');
77 $mockController->expects($this->at(3))->method(
'initializeAction');
78 $mockController->expects($this->at(4))->method(
'initializeFooAction');
79 $mockController->expects($this->at(5))->method(
'mapRequestArgumentsToControllerArguments');
80 $mockController->expects($this->at(6))->method(
'checkRequestHash');
81 $mockController->expects($this->at(7))->method(
'buildControllerContext');
82 $mockController->expects($this->at(8))->method(
'resolveView');
84 $mockController->_set(
'mvcPropertyMappingConfigurationService', $configurationService);
85 $mockController->_set(
'arguments',
new \
TYPO3\CMS\Extbase\Mvc\Controller\Arguments());
87 $mockController->processRequest($mockRequest, $mockResponse);
88 $this->assertSame($mockRequest, $mockController->_get(
'request'));
89 $this->assertSame($mockResponse, $mockController->_get(
'response'));
97 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
98 $mockResponse = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\ResponseInterface', array(), array(),
'', FALSE);
99 $mockResponse->expects($this->once())->method(
'appendContent')->with(
'the returned string');
100 $mockArguments = new \ArrayObject();
101 $mockArgumentMappingResults = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(),
'', FALSE);
102 $mockArgumentMappingResults->expects($this->once())->method(
'hasErrors')->will($this->returnValue(FALSE));
103 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction',
'initializeAction'), array(),
'', FALSE);
104 $mockSignalSlotDispatcher = $this->getMock(
'TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(),
'', FALSE);
105 $mockController->_set(
'signalSlotDispatcher', $mockSignalSlotDispatcher);
107 $mockController->expects($this->once())->method(
'fooAction')->will($this->returnValue(
'the returned string'));
108 $mockController->_set(
'request', $mockRequest);
109 $mockController->_set(
'response', $mockResponse);
110 $mockController->_set(
'arguments', $mockArguments);
111 $mockController->_set(
'actionMethodName',
'fooAction');
112 $mockController->_set(
'argumentsMappingResults', $mockArgumentMappingResults);
113 $mockController->_call(
'callActionMethod');
121 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
122 $mockResponse = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\ResponseInterface', array(), array(),
'', FALSE);
123 $mockResponse->expects($this->once())->method(
'appendContent')->with(
'the view output');
124 $mockView = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface');
125 $mockView->expects($this->once())->method(
'render')->will($this->returnValue(
'the view output'));
126 $mockArguments = new \ArrayObject();
127 $mockArgumentMappingResults = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(),
'', FALSE);
128 $mockArgumentMappingResults->expects($this->once())->method(
'hasErrors')->will($this->returnValue(FALSE));
129 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction',
'initializeAction'), array(),
'', FALSE);
130 $mockSignalSlotDispatcher = $this->getMock(
'TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(),
'', FALSE);
131 $mockController->_set(
'signalSlotDispatcher', $mockSignalSlotDispatcher);
133 $mockController->expects($this->once())->method(
'fooAction');
134 $mockController->_set(
'request', $mockRequest);
135 $mockController->_set(
'response', $mockResponse);
136 $mockController->_set(
'arguments', $mockArguments);
137 $mockController->_set(
'actionMethodName',
'fooAction');
138 $mockController->_set(
'argumentsMappingResults', $mockArgumentMappingResults);
139 $mockController->_set(
'view', $mockView);
140 $mockController->_call(
'callActionMethod');
148 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
149 $mockResponse = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\ResponseInterface', array(), array(),
'', FALSE);
150 $mockResponse->expects($this->once())->method(
'appendContent')->with(
'the returned string');
151 $mockArguments = new \ArrayObject();
152 $mockArgumentMappingResults = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(),
'', FALSE);
153 $mockArgumentMappingResults->expects($this->once())->method(
'hasErrors')->will($this->returnValue(TRUE));
154 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'barAction',
'initializeAction'), array(),
'', FALSE);
156 $mockController->expects($this->once())->method(
'barAction')->will($this->returnValue(
'the returned string'));
157 $mockController->_set(
'request', $mockRequest);
158 $mockController->_set(
'response', $mockResponse);
159 $mockController->_set(
'arguments', $mockArguments);
160 $mockController->_set(
'actionMethodName',
'fooAction');
161 $mockController->_set(
'errorMethodName',
'barAction');
162 $mockController->_set(
'argumentsMappingResults', $mockArgumentMappingResults);
163 $mockController->_call(
'callActionMethod');
171 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
172 $mockResponse = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\ResponseInterface', array(), array(),
'', FALSE);
173 $arguments = new \ArrayObject();
174 $optionalArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument(
'name1',
'Text');
175 $optionalArgument->setDefaultValue(
'Default value');
176 $arguments[] = $optionalArgument;
177 $mockArgumentMappingResults = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(), array(),
'', FALSE);
178 $mockArgumentMappingResults->expects($this->once())->method(
'hasErrors')->will($this->returnValue(FALSE));
179 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction',
'initializeAction'), array(),
'', FALSE);
180 $mockSignalSlotDispatcher = $this->getMock(
'TYPO3\\CMS\Extbase\\SignalSlot\\Dispatcher', array(), array(),
'', FALSE);
181 $mockController->_set(
'signalSlotDispatcher', $mockSignalSlotDispatcher);
183 $mockController->expects($this->once())->method(
'fooAction')->with(
'Default value');
184 $mockController->_set(
'request', $mockRequest);
185 $mockController->_set(
'response', $mockResponse);
186 $mockController->_set(
'arguments', $arguments);
187 $mockController->_set(
'actionMethodName',
'fooAction');
188 $mockController->_set(
'argumentsMappingResults', $mockArgumentMappingResults);
189 $mockController->_call(
'callActionMethod');
197 $mockSession = $this->getMock(
'Tx_Extbase_Session_SessionInterface');
198 $mockControllerContext = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(),
'', FALSE);
199 $mockFluidTemplateView = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface');
200 $mockFluidTemplateView->expects($this->once())->method(
'setControllerContext')->with($mockControllerContext);
201 $mockFluidTemplateView->expects($this->once())->method(
'canRender')->with($mockControllerContext)->will($this->returnValue(TRUE));
202 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(),
'', FALSE);
203 $mockObjectManager->expects($this->at(0))->method(
'get')->with(
'TYPO3\\CMS\\Fluid\\View\\TemplateView')->will($this->returnValue($mockFluidTemplateView));
204 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'buildControllerContext',
'resolveViewObjectName',
'setViewConfiguration'), array(),
'', FALSE);
205 $mockController->expects($this->once())->method(
'resolveViewObjectName')->will($this->returnValue(FALSE));
206 $mockController->_set(
'session', $mockSession);
208 $mockController->_set(
'controllerContext', $mockControllerContext);
209 $this->assertSame($mockFluidTemplateView, $mockController->_call(
'resolveView'));
217 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
218 $mockRequest->expects($this->once())->method(
'getControllerVendorName')->will($this->returnValue(
'MyVendor'));
219 $mockRequest->expects($this->once())->method(
'getControllerExtensionName')->will($this->returnValue(
'MyPackage'));
220 $mockRequest->expects($this->once())->method(
'getControllerName')->will($this->returnValue(
'MyController'));
221 $mockRequest->expects($this->once())->method(
'getControllerActionName')->will($this->returnValue(
'MyAction'));
222 $mockRequest->expects($this->atLeastOnce())->method(
'getFormat')->will($this->returnValue(
'MyFormat'));
223 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(),
'', FALSE);
224 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
225 $mockController->_set(
'request', $mockRequest);
227 $mockController->_set(
'namespacesViewObjectNamePattern',
'RandomViewObject@vendor\@extension\View\@controller\@action@format');
228 $mockController->_call(
'resolveViewObjectName');
235 eval(
'class Tx_MyPackage_View_MyController_MyActionMyFormat {}');
237 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
238 $mockRequest->expects($this->once())->method(
'getControllerExtensionName')->will($this->returnValue(
'MyPackage'));
239 $mockRequest->expects($this->once())->method(
'getControllerName')->will($this->returnValue(
'MyController'));
240 $mockRequest->expects($this->once())->method(
'getControllerActionName')->will($this->returnValue(
'MyAction'));
241 $mockRequest->expects($this->once())->method(
'getControllerVendorName')->will($this->returnValue(NULL));
242 $mockRequest->expects($this->atLeastOnce())->method(
'getFormat')->will($this->returnValue(
'MyFormat'));
243 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(),
'', FALSE);
244 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
245 $mockController->_set(
'request', $mockRequest);
249 'Tx_MyPackage_View_MyController_MyActionMyFormat',
250 $mockController->_call(
'resolveViewObjectName')
258 eval(
'namespace MyVendor\MyPackage\View\MyController; class MyActionMyFormat {}');
260 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
261 $mockRequest->expects($this->once())->method(
'getControllerExtensionName')->will($this->returnValue(
'MyPackage'));
262 $mockRequest->expects($this->once())->method(
'getControllerName')->will($this->returnValue(
'MyController'));
263 $mockRequest->expects($this->once())->method(
'getControllerActionName')->will($this->returnValue(
'MyAction'));
264 $mockRequest->expects($this->once())->method(
'getControllerVendorName')->will($this->returnValue(
'MyVendor'));
265 $mockRequest->expects($this->atLeastOnce())->method(
'getFormat')->will($this->returnValue(
'MyFormat'));
266 $mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface', array(), array(),
'', FALSE);
267 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
268 $mockController->_set(
'request', $mockRequest);
272 'MyVendor\MyPackage\View\MyController\MyActionMyFormat',
273 $mockController->_call(
'resolveViewObjectName')
281 public function resolveActionMethodNameReturnsTheCurrentActionMethodNameFromTheRequest() {
282 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
283 $mockRequest->expects($this->once())->method(
'getControllerActionName')->will($this->returnValue(
'fooBar'));
285 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooBarAction'), array(),
'', FALSE);
286 $mockController->_set(
'request', $mockRequest);
287 $this->assertEquals(
'fooBarAction', $mockController->_call(
'resolveActionMethodName'));
295 public function resolveActionMethodNameThrowsAnExceptionIfTheActionDefinedInTheRequestDoesNotExist() {
296 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
297 $mockRequest->expects($this->once())->method(
'getControllerActionName')->will($this->returnValue(
'fooBar'));
299 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'otherBarAction'), array(),
'', FALSE);
300 $mockController->_set(
'request', $mockRequest);
301 $mockController->_call(
'resolveActionMethodName');
309 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
310 $mockArguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(
'addNewArgument',
'removeAll'));
311 $mockArguments->expects($this->at(0))->method(
'addNewArgument')->with(
'stringArgument',
'string', TRUE);
312 $mockArguments->expects($this->at(1))->method(
'addNewArgument')->with(
'integerArgument',
'integer', TRUE);
313 $mockArguments->expects($this->at(2))->method(
'addNewArgument')->with(
'objectArgument',
'F3_Foo_Bar', TRUE);
314 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction',
'evaluateDontValidateAnnotations'), array(),
'', FALSE);
315 $methodParameters = array(
316 'stringArgument' => array(
318 'byReference' => FALSE,
321 'allowsNull' => FALSE,
324 'integerArgument' => array(
326 'byReference' => FALSE,
329 'allowsNull' => FALSE,
332 'objectArgument' => array(
334 'byReference' => FALSE,
337 'allowsNull' => FALSE,
338 'type' =>
'F3_Foo_Bar' 341 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
342 $mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodParameters));
343 $mockController->_set(
'reflectionService', $mockReflectionService);
344 $mockController->_set(
'request', $mockRequest);
345 $mockController->_set(
'arguments', $mockArguments);
346 $mockController->_set(
'actionMethodName',
'fooAction');
347 $mockController->_call(
'initializeActionMethodArguments');
355 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
356 $mockArguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(), array(),
'', FALSE);
357 $mockArguments->expects($this->at(0))->method(
'addNewArgument')->with(
'arg1',
'string', TRUE);
358 $mockArguments->expects($this->at(1))->method(
'addNewArgument')->with(
'arg2',
'array', FALSE, array(21));
359 $mockArguments->expects($this->at(2))->method(
'addNewArgument')->with(
'arg3',
'string', FALSE, 42);
360 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction',
'evaluateDontValidateAnnotations'), array(),
'', FALSE);
361 $methodParameters = array(
364 'byReference' => FALSE,
367 'allowsNull' => FALSE,
372 'byReference' => FALSE,
375 'defaultValue' => array(21),
376 'allowsNull' => FALSE
380 'byReference' => FALSE,
383 'defaultValue' => 42,
384 'allowsNull' => FALSE,
388 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
389 $mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodParameters));
390 $mockController->_set(
'reflectionService', $mockReflectionService);
391 $mockController->_set(
'request', $mockRequest);
392 $mockController->_set(
'arguments', $mockArguments);
393 $mockController->_set(
'actionMethodName',
'fooAction');
394 $mockController->_call(
'initializeActionMethodArguments');
403 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
404 $mockArguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(), array(),
'', FALSE);
405 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction'), array(),
'', FALSE);
406 $methodParameters = array(
409 'byReference' => FALSE,
412 'allowsNull' => FALSE
415 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
416 $mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodParameters));
417 $mockController->_set(
'reflectionService', $mockReflectionService);
418 $mockController->_set(
'request', $mockRequest);
419 $mockController->_set(
'arguments', $mockArguments);
420 $mockController->_set(
'actionMethodName',
'fooAction');
421 $mockController->_call(
'initializeActionMethodArguments');
429 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction'), array(),
'', FALSE);
431 $argument = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getName'), array(),
'', FALSE);
432 $argument->expects($this->any())->method(
'getName')->will($this->returnValue(
'arg1'));
433 $arguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(
'dummy'));
434 $arguments->addArgument($argument);
435 $methodTagsValues = array();
436 $methodArgumentsValidatorConjunctions = array();
437 $methodArgumentsValidatorConjunctions[
'arg1'] = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(),
'', FALSE);
438 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
439 $mockReflectionService->expects($this->once())->method(
'getMethodTagsValues')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodTagsValues));
440 $mockValidatorResolver = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array(), array(),
'', FALSE);
441 $mockValidatorResolver->expects($this->once())->method(
'buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
442 $mockController->_set(
'reflectionService', $mockReflectionService);
443 $mockController->_set(
'validatorResolver', $mockValidatorResolver);
444 $mockController->_set(
'arguments', $arguments);
445 $mockController->_set(
'actionMethodName',
'fooAction');
446 $mockController->_call(
'initializeActionMethodValidators');
447 $this->assertEquals($methodArgumentsValidatorConjunctions[
'arg1'], $arguments[
'arg1']->getValidator());
455 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction'), array(),
'', FALSE);
457 $argument = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getName',
'getDataType'), array(),
'', FALSE);
458 $argument->expects($this->any())->method(
'getName')->will($this->returnValue(
'arg1'));
459 $argument->expects($this->any())->method(
'getDataType')->will($this->returnValue(
'F3_Foo_Quux'));
460 $arguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(
'dummy'));
461 $arguments->addArgument($argument);
462 $methodTagsValues = array();
463 $quuxBaseValidatorConjunction = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(),
'', FALSE);
464 $methodArgumentsValidatorConjunctions = array();
465 $methodArgumentsValidatorConjunctions[
'arg1'] = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(),
'', FALSE);
466 $methodArgumentsValidatorConjunctions[
'arg1']->expects($this->once())->method(
'addValidator')->with($quuxBaseValidatorConjunction);
467 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
468 $mockReflectionService->expects($this->once())->method(
'getMethodTagsValues')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodTagsValues));
469 $mockValidatorResolver = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array(), array(),
'', FALSE);
470 $mockValidatorResolver->expects($this->once())->method(
'buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
471 $mockValidatorResolver->expects($this->once())->method(
'getBaseValidatorConjunction')->with(
'F3_Foo_Quux')->will($this->returnValue($quuxBaseValidatorConjunction));
472 $mockController->_set(
'reflectionService', $mockReflectionService);
473 $mockController->_set(
'validatorResolver', $mockValidatorResolver);
474 $mockController->_set(
'arguments', $arguments);
475 $mockController->_set(
'actionMethodName',
'fooAction');
476 $mockController->_call(
'initializeActionMethodValidators');
477 $this->assertEquals($methodArgumentsValidatorConjunctions[
'arg1'], $arguments[
'arg1']->getValidator());
485 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'fooAction'), array(),
'', FALSE);
487 $argument = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getName',
'getDataType'), array(),
'', FALSE);
488 $argument->expects($this->any())->method(
'getName')->will($this->returnValue(
'arg1'));
489 $argument->expects($this->any())->method(
'getDataType')->will($this->returnValue(
'F3_Foo_Quux'));
490 $arguments = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array(
'dummy'));
491 $arguments->addArgument($argument);
492 $methodTagsValues = array(
493 'dontvalidate' => array(
497 $methodArgumentsValidatorConjunctions = array();
498 $methodArgumentsValidatorConjunctions[
'arg1'] = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(),
'', FALSE);
499 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(), array(),
'', FALSE);
500 $mockReflectionService->expects($this->once())->method(
'getMethodTagsValues')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodTagsValues));
501 $mockValidatorResolver = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver', array(), array(),
'', FALSE);
502 $mockValidatorResolver->expects($this->once())->method(
'buildMethodArgumentsValidatorConjunctions')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodArgumentsValidatorConjunctions));
503 $mockValidatorResolver->expects($this->any())->method(
'getBaseValidatorConjunction')->will($this->throwException(
new \
Exception(
'This should not be called because the dontvalidate annotation is set.')));
504 $mockController->_set(
'reflectionService', $mockReflectionService);
505 $mockController->_set(
'validatorResolver', $mockValidatorResolver);
506 $mockController->_set(
'arguments', $arguments);
507 $mockController->_set(
'actionMethodName',
'fooAction');
508 $mockController->_call(
'initializeActionMethodValidators');
509 $this->assertEquals($methodArgumentsValidatorConjunctions[
'arg1'], $arguments[
'arg1']->getValidator());
516 public function defaultErrorActionSetsArgumentMappingResultsErrorsInRequest() {
517 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(),
'', FALSE);
518 $mockError = $this->getMock(
'TYPO3\\CMS\\Extbase\\Error\\Error', array(
'getMessage'), array(),
'', FALSE);
519 $mockArgumentsMappingResults = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\MappingResults', array(
'getErrors',
'getWarnings'), array(),
'', FALSE);
520 $mockArgumentsMappingResults->expects($this->atLeastOnce())->method(
'getErrors')->will($this->returnValue(array($mockError)));
521 $mockArgumentsMappingResults->expects($this->any())->method(
'getWarnings')->will($this->returnValue(array()));
523 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'clearCacheOnError'), array(),
'', FALSE);
524 $controllerContext = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(
'getFlashMessageQueue'));
525 $controllerContext->expects($this->any())->method(
'getFlashMessageQueue')->will($this->returnValue(
new \
TYPO3\CMS\Core\Messaging\FlashMessageQueue(
'foo')));
527 $mockController->_set(
'controllerContext', $controllerContext);
528 $mockController->_set(
'request', $mockRequest);
529 $mockController->_set(
'argumentsMappingResults', $mockArgumentsMappingResults);
530 $mockRequest->expects($this->once())->method(
'setErrors')->with(array($mockError));
531 $mockController->_call(
'errorAction');
544 array(FALSE, FALSE, \
TYPO3\CMS\Extbase\Mvc\Controller\Argument::ORIGIN_PERSISTENCE, \
TYPO3\CMS\Extbase\Mvc\Controller\Argument::ORIGIN_PERSISTENCE),
546 array(FALSE, TRUE, \
TYPO3\CMS\Extbase\Mvc\Controller\Argument::ORIGIN_PERSISTENCE, \
TYPO3\CMS\Extbase\Mvc\Controller\Argument::ORIGIN_PERSISTENCE_AND_MODIFIED, array(
'dontverifyrequesthash' =>
''))
561 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array(
'isHmacVerified'), array(),
'', FALSE);
562 $mockRequest->expects($this->once())->method(
'isHmacVerified')->will($this->returnValue($hmacVerified));
563 $argument1 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getOrigin'), array(),
'', FALSE);
564 $argument1->expects($this->any())->method(
'getOrigin')->will($this->returnValue($argument1Origin));
565 $argument2 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getOrigin'), array(),
'', FALSE);
566 $argument2->expects($this->any())->method(
'getOrigin')->will($this->returnValue($argument2Origin));
567 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
569 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(
'getMethodTagsValues'), array(),
'', FALSE);
570 if ($reflectionServiceNeedsInitialization) {
572 $mockReflectionService->expects($this->any())->method(
'getMethodTagsValues')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodTagsValues));
574 $mockController->_set(
'arguments', array($argument1, $argument2));
575 $mockController->_set(
'request', $mockRequest);
576 $mockController->_set(
'actionMethodName',
'fooAction');
577 $mockController->_set(
'reflectionService', $mockReflectionService);
578 $mockController->_call(
'checkRequestHash');
587 $hmacVerified = FALSE;
590 $methodTagsValues = array();
591 $mockRequest = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array(
'isHmacVerified'), array(),
'', FALSE);
592 $mockRequest->expects($this->once())->method(
'isHmacVerified')->will($this->returnValue($hmacVerified));
593 $argument1 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getOrigin'), array(),
'', FALSE);
594 $argument1->expects($this->any())->method(
'getOrigin')->will($this->returnValue($argument1Origin));
595 $argument2 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'getOrigin'), array(),
'', FALSE);
596 $argument2->expects($this->any())->method(
'getOrigin')->will($this->returnValue($argument2Origin));
597 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
599 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array(
'getMethodTagsValues'), array(),
'', FALSE);
600 $mockReflectionService->expects($this->any())->method(
'getMethodTagsValues')->with(get_class($mockController),
'fooAction')->will($this->returnValue($methodTagsValues));
601 $mockController->_set(
'arguments', array($argument1, $argument2));
602 $mockController->_set(
'request', $mockRequest);
603 $mockController->_set(
'actionMethodName',
'fooAction');
604 $mockController->_set(
'reflectionService', $mockReflectionService);
605 $mockController->_call(
'checkRequestHash');
614 $mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
615 $mockConfigurationManager->expects($this->any())->method(
'isFeatureEnabled')->with(
'rewrittenPropertyMapper')->will($this->returnValue(FALSE));
616 $actionController->injectConfigurationManager($mockConfigurationManager);
626 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
627 $mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
628 $mockConfigurationManager->expects($this->any())->method(
'getConfiguration')->will($this->returnValue($configuration));
629 $mockController->injectConfigurationManager($mockConfigurationManager);
630 $mockController->_set(
'request', $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request'), array(
'getControllerExtensionKey'));
631 $view = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface', array(
'setControllerContext',
'assign',
'assignMultiple',
'canRender',
'render',
'initializeView',
'setTemplateRootPaths'));
632 $view->expects($this->once())->method(
'setTemplateRootPaths')->with($expected);
633 $mockController->_call(
'setViewConfiguration', $view);
641 'old behaviour only' => array(
644 'templateRootPath' =>
'some path' 649 'new behaviour only with text keys' => array(
652 'templateRootPaths' => array(
653 'default' =>
'some path',
654 'extended' =>
'some other path' 659 'extended' =>
'some other path',
660 'default' =>
'some path' 663 'new behaviour only with numerical keys' => array(
666 'templateRootPaths' => array(
668 '20' =>
'some other path',
669 '15' =>
'intermediate specific path' 674 '20' =>
'some other path',
675 '15' =>
'intermediate specific path',
679 'new behaviour only with mixed keys' => array(
682 'templateRootPaths' => array(
684 'very_specific' =>
'some other path',
685 '15' =>
'intermediate specific path' 690 '15' =>
'intermediate specific path',
691 'very_specific' =>
'some other path',
695 'old and new behaviour mixed with text keys' => array(
698 'templateRootPaths' => array(
699 'default' =>
'some path',
700 'specific' =>
'intermediate specific path',
701 'very_specific' =>
'some other path' 703 'templateRootPath' =>
'old path' 707 'very_specific' =>
'some other path',
708 'specific' =>
'intermediate specific path',
709 'default' =>
'some path',
713 'old and new behaviour mixed with numerical keys' => array(
716 'templateRootPaths' => array(
718 '20' =>
'intermediate specific path',
719 '30' =>
'some other path' 721 'templateRootPath' =>
'old path' 725 '30' =>
'some other path',
726 '20' =>
'intermediate specific path',
731 'old and new behaviour mixed with mixed keys' => array(
734 'templateRootPaths' => array(
736 'very_specific' =>
'some other path',
737 '15' =>
'intermediate specific path' 739 'templateRootPath' =>
'old path' 743 '15' =>
'intermediate specific path',
744 'very_specific' =>
'some other path',
760 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
761 $mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
762 $mockConfigurationManager->expects($this->any())->method(
'getConfiguration')->will($this->returnValue($configuration));
763 $mockController->injectConfigurationManager($mockConfigurationManager);
764 $mockController->_set(
'request', $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request'), array(
'getControllerExtensionKey'));
765 $view = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface', array(
'setControllerContext',
'assign',
'assignMultiple',
'canRender',
'render',
'initializeView',
'setlayoutRootPaths'));
766 $view->expects($this->once())->method(
'setlayoutRootPaths')->with($expected);
767 $mockController->_call(
'setViewConfiguration', $view);
775 'old behaviour only' => array(
778 'layoutRootPath' =>
'some path' 783 'new behaviour only with text keys' => array(
786 'layoutRootPaths' => array(
787 'default' =>
'some path',
788 'extended' =>
'some other path' 793 'extended' =>
'some other path',
794 'default' =>
'some path' 797 'new behaviour only with numerical keys' => array(
800 'layoutRootPaths' => array(
802 '20' =>
'some other path',
803 '15' =>
'intermediate specific path' 808 '20' =>
'some other path',
809 '15' =>
'intermediate specific path',
813 'new behaviour only with mixed keys' => array(
816 'layoutRootPaths' => array(
818 'very_specific' =>
'some other path',
819 '15' =>
'intermediate specific path' 824 '15' =>
'intermediate specific path',
825 'very_specific' =>
'some other path',
829 'old and new behaviour mixed with text keys' => array(
832 'layoutRootPaths' => array(
833 'default' =>
'some path',
834 'specific' =>
'intermediate specific path',
835 'very_specific' =>
'some other path' 837 'layoutRootPath' =>
'old path' 841 'very_specific' =>
'some other path',
842 'specific' =>
'intermediate specific path',
843 'default' =>
'some path',
847 'old and new behaviour mixed with numerical keys' => array(
850 'layoutRootPaths' => array(
852 '20' =>
'intermediate specific path',
853 '30' =>
'some other path' 855 'layoutRootPath' =>
'old path' 859 '30' =>
'some other path',
860 '20' =>
'intermediate specific path',
865 'old and new behaviour mixed with mixed keys' => array(
868 'layoutRootPaths' => array(
870 'very_specific' =>
'some other path',
871 '15' =>
'intermediate specific path' 873 'layoutRootPath' =>
'old path' 877 '15' =>
'intermediate specific path',
878 'very_specific' =>
'some other path',
894 $mockController = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array(
'dummy'), array(),
'', FALSE);
895 $mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
896 $mockConfigurationManager->expects($this->any())->method(
'getConfiguration')->will($this->returnValue($configuration));
897 $mockController->injectConfigurationManager($mockConfigurationManager);
898 $mockController->_set(
'request', $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Request'), array(
'getControllerExtensionKey'));
899 $view = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface', array(
'setControllerContext',
'assign',
'assignMultiple',
'canRender',
'render',
'initializeView',
'setpartialRootPaths'));
900 $view->expects($this->once())->method(
'setpartialRootPaths')->with($expected);
901 $mockController->_call(
'setViewConfiguration', $view);
909 'old behaviour only' => array(
912 'partialRootPath' =>
'some path' 917 'new behaviour only with text keys' => array(
920 'partialRootPaths' => array(
921 'default' =>
'some path',
922 'extended' =>
'some other path' 927 'extended' =>
'some other path',
928 'default' =>
'some path' 931 'new behaviour only with numerical keys' => array(
934 'partialRootPaths' => array(
936 '20' =>
'some other path',
937 '15' =>
'intermediate specific path' 942 '20' =>
'some other path',
943 '15' =>
'intermediate specific path',
947 'new behaviour only with mixed keys' => array(
950 'partialRootPaths' => array(
952 'very_specific' =>
'some other path',
953 '15' =>
'intermediate specific path' 958 '15' =>
'intermediate specific path',
959 'very_specific' =>
'some other path',
963 'old and new behaviour mixed with text keys' => array(
966 'partialRootPath' =>
'old path',
967 'partialRootPaths' => array(
968 'default' =>
'some path',
969 'specific' =>
'intermediate specific path',
970 'very_specific' =>
'some other path' 975 'very_specific' =>
'some other path',
976 'specific' =>
'intermediate specific path',
977 'default' =>
'some path',
981 'old and new behaviour mixed with numerical keys' => array(
984 'partialRootPaths' => array(
986 '20' =>
'intermediate specific path',
987 '30' =>
'some other path' 989 'partialRootPath' =>
'old path' 993 '30' =>
'some other path',
994 '20' =>
'intermediate specific path',
999 'old and new behaviour mixed with mixed keys' => array(
1002 'partialRootPaths' => array(
1003 '10' =>
'some path',
1004 'very_specific' =>
'some other path',
1005 '15' =>
'intermediate specific path' 1007 'partialRootPath' =>
'old path' 1011 '15' =>
'intermediate specific path',
1012 'very_specific' =>
'some other path',
1013 '10' =>
'some path',
initializeActionMethodArgumentsThrowsExceptionIfDataTypeWasNotSpecified()
templateRootPathDataProvider()
resolveViewUsesFluidTemplateViewIfTemplateIsAvailable()
checkRequestHashDoesNotThrowExceptionInNormalOperations($hmacVerified, $reflectionServiceNeedsInitialization=FALSE, $argument1Origin=3, $argument2Origin=3, array $methodTagsValues=array())
checkRequestHashInNormalOperation()
resolveViewObjectNameUsesViewObjectNamePatternToResolveViewObjectName()
initializeActionMethodValidatorsRegistersModelBasedValidators()
callActionMethodAppendsStringsReturnedByActionMethodToTheResponseObject()
setViewConfigurationResolvesTemplateRootPathsForTemplateRootPath($configuration, $expected)
initializeActionMethodValidatorsDoesNotRegisterModelBasedValidatorsIfDontValidateAnnotationIsSet()
layoutRootPathDataProvider()
initializeActionMethodArgumentsRegistersArgumentsFoundInTheSignatureOfTheCurrentActionMethod()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
setViewConfigurationResolvesLayoutRootPathsForLayoutRootPath($configuration, $expected)
checkRequestHashThrowsExceptionIfNeeded()
const ORIGIN_PERSISTENCE_AND_MODIFIED
callActionMethodRendersTheViewAutomaticallyIfTheActionReturnedNullAndAViewExists()
resolveViewObjectNameUsesNamespacedViewObjectNamePatternForExtensionsWithVendor()
enableDeprecatedPropertyMapperInController(\TYPO3\CMS\Extbase\Mvc\Controller\ActionController $actionController)
callActionMethodCallsTheErrorActionIfTheMappingResultsHaveErrors()
partialRootPathDataProvider()
$mockMvcPropertyMappingConfigurationService
callActionMethodPassesDefaultValuesAsArguments()
setViewConfigurationResolvesPartialRootPathsForPartialRootPath($configuration, $expected)
initializeActionMethodValidatorsCorrectlyRegistersValidatorsBasedOnDataType()
resolveViewObjectNameUsesDeprecatedViewObjectNamePatternForExtensionsWithoutVendor()
initializeActionMethodArgumentsRegistersOptionalArgumentsAsSuch()