70 $this->request = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Request', array(
'dummy'));
71 $this->mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
72 $this->mockObjectManager->expects($this->any())->method(
'get')->with(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Request')->will($this->returnValue($this->request));
73 $this->mockCommand = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', array(), array(),
'', FALSE);
74 $this->mockCommand->expects($this->any())->method(
'getControllerClassName')->will($this->returnValue(
'Tx_SomeExtensionName_Command_DefaultCommandController'));
75 $this->mockCommand->expects($this->any())->method(
'getControllerCommandName')->will($this->returnValue(
'list'));
76 $this->mockCommandManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandManager');
77 $this->mockCommandManager->expects($this->any())->method(
'getCommandByIdentifier')->with(
'some_extension_name:default:list')->will($this->returnValue($this->mockCommand));
78 $this->mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
79 $this->mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
80 $this->requestBuilder = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder', array(
'dummy'));
81 $this->requestBuilder->_set(
'objectManager', $this->mockObjectManager);
82 $this->requestBuilder->_set(
'reflectionService', $this->mockReflectionService);
83 $this->requestBuilder->_set(
'commandManager', $this->mockCommandManager);
84 $this->requestBuilder->_set(
'configurationManager', $this->mockConfigurationManager);
94 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->will($this->returnValue(array()));
95 $request = $this->requestBuilder->build(
'some_extension_name:default:list');
96 $this->assertSame(
'Tx_SomeExtensionName_Command_DefaultCommandController',
$request->getControllerObjectName());
97 $this->assertSame(
'list',
$request->getControllerCommandName(),
'The CLI request specifying a package, controller and action name did not return a request object pointing to the expected action.');
108 $this->mockCommandManager->getCommandByIdentifier(
'some_extension_name:default:list');
110 $mockCommandManager->expects($this->any())->method(
'getCommandByIdentifier')->with(
'test:default:list')->will($this->throwException(
new \
TYPO3\CMS\Extbase\Mvc\
Exception\NoSuchCommandException()));
112 $request = $this->requestBuilder->build(
'test:default:list');
113 $this->assertSame(
'TYPO3\\CMS\\Extbase\\Command\\HelpCommandController',
$request->getControllerObjectName());
120 $methodParameters = array(
121 'testArgument' => array(
'optional' => FALSE,
'type' =>
'string')
123 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
124 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument=value');
125 $this->assertTrue(
$request->hasArgument(
'testArgument'),
'The given "testArgument" was not found in the built request.');
126 $this->assertSame(
$request->getArgument(
'testArgument'),
'value',
'The "testArgument" had not the given value.');
136 $methodParameters = array(
137 'testArgument' => array(
'optional' => FALSE,
'type' =>
'string'),
138 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string')
140 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
141 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument=value --test-argument2=value2');
142 $this->assertTrue(
$request->hasArgument(
'testArgument'),
'The given "testArgument" was not found in the built request.');
143 $this->assertTrue(
$request->hasArgument(
'testArgument2'),
'The given "testArgument2" was not found in the built request.');
144 $this->assertEquals(
$request->getArgument(
'testArgument'),
'value',
'The "testArgument" had not the given value.');
145 $this->assertEquals(
$request->getArgument(
'testArgument2'),
'value2',
'The "testArgument2" had not the given value.');
155 $methodParameters = array(
156 'testArgument' => array(
'optional' => FALSE,
'type' =>
'string'),
157 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string'),
158 'testArgument3' => array(
'optional' => FALSE,
'type' =>
'string'),
159 'testArgument4' => array(
'optional' => FALSE,
'type' =>
'string')
161 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
162 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument= value --test-argument2 =value2 --test-argument3 = value3 --test-argument4=value4');
163 $this->assertTrue(
$request->hasArgument(
'testArgument'),
'The given "testArgument" was not found in the built request.');
164 $this->assertTrue(
$request->hasArgument(
'testArgument2'),
'The given "testArgument2" was not found in the built request.');
165 $this->assertTrue(
$request->hasArgument(
'testArgument3'),
'The given "testArgument3" was not found in the built request.');
166 $this->assertTrue(
$request->hasArgument(
'testArgument4'),
'The given "testArgument4" was not found in the built request.');
167 $this->assertSame(
$request->getArgument(
'testArgument'),
'value',
'The "testArgument" had not the given value.');
168 $this->assertSame(
$request->getArgument(
'testArgument2'),
'value2',
'The "testArgument2" had not the given value.');
169 $this->assertSame(
$request->getArgument(
'testArgument3'),
'value3',
'The "testArgument3" had not the given value.');
170 $this->assertSame(
$request->getArgument(
'testArgument4'),
'value4',
'The "testArgument4" had not the given value.');
180 $methodParameters = array(
181 'a' => array(
'optional' => FALSE,
'type' =>
'string'),
182 'd' => array(
'optional' => FALSE,
'type' =>
'string'),
183 'f' => array(
'optional' => FALSE,
'type' =>
'string')
185 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
186 $request = $this->requestBuilder->build(
'some_extension_name:default:list -d valued -f=valuef -a = valuea');
187 $this->assertTrue(
$request->hasArgument(
'd'),
'The given "d" was not found in the built request.');
188 $this->assertTrue(
$request->hasArgument(
'f'),
'The given "f" was not found in the built request.');
189 $this->assertTrue(
$request->hasArgument(
'a'),
'The given "a" was not found in the built request.');
190 $this->assertSame(
$request->getArgument(
'd'),
'valued',
'The "d" had not the given value.');
191 $this->assertSame(
$request->getArgument(
'f'),
'valuef',
'The "f" had not the given value.');
192 $this->assertSame(
$request->getArgument(
'a'),
'valuea',
'The "a" had not the given value.');
203 $methodParameters = array(
204 'testArgument' => array(
'optional' => FALSE,
'type' =>
'string'),
205 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string'),
206 'testArgument3' => array(
'optional' => FALSE,
'type' =>
'string'),
207 'testArgument4' => array(
'optional' => FALSE,
'type' =>
'string'),
208 'testArgument5' => array(
'optional' => FALSE,
'type' =>
'string'),
209 'testArgument6' => array(
'optional' => FALSE,
'type' =>
'string'),
210 'testArgument7' => array(
'optional' => FALSE,
'type' =>
'string'),
211 'f' => array(
'optional' => FALSE,
'type' =>
'string'),
212 'd' => array(
'optional' => FALSE,
'type' =>
'string'),
213 'a' => array(
'optional' => FALSE,
'type' =>
'string'),
214 'c' => array(
'optional' => FALSE,
'type' =>
'string'),
215 'j' => array(
'optional' => FALSE,
'type' =>
'string'),
216 'k' => array(
'optional' => FALSE,
'type' =>
'string'),
217 'm' => array(
'optional' => FALSE,
'type' =>
'string')
219 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
220 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument=value --test-argument2= value2 -k --test-argument-3 = value3 --test-argument4=value4 -f valuef -d=valued -a = valuea -c --testArgument7 --test-argument5 = 5 --test-argument6 -j kjk -m');
221 $this->assertTrue(
$request->hasArgument(
'testArgument'),
'The given "testArgument" was not found in the built request.');
222 $this->assertTrue(
$request->hasArgument(
'testArgument2'),
'The given "testArgument2" was not found in the built request.');
223 $this->assertTrue(
$request->hasArgument(
'k'),
'The given "k" was not found in the built request.');
224 $this->assertTrue(
$request->hasArgument(
'testArgument3'),
'The given "testArgument3" was not found in the built request.');
225 $this->assertTrue(
$request->hasArgument(
'testArgument4'),
'The given "testArgument4" was not found in the built request.');
226 $this->assertTrue(
$request->hasArgument(
'f'),
'The given "f" was not found in the built request.');
227 $this->assertTrue(
$request->hasArgument(
'd'),
'The given "d" was not found in the built request.');
228 $this->assertTrue(
$request->hasArgument(
'a'),
'The given "a" was not found in the built request.');
229 $this->assertTrue(
$request->hasArgument(
'c'),
'The given "d" was not found in the built request.');
230 $this->assertTrue(
$request->hasArgument(
'testArgument7'),
'The given "testArgument7" was not found in the built request.');
231 $this->assertTrue(
$request->hasArgument(
'testArgument5'),
'The given "testArgument5" was not found in the built request.');
232 $this->assertTrue(
$request->hasArgument(
'testArgument6'),
'The given "testArgument6" was not found in the built request.');
233 $this->assertTrue(
$request->hasArgument(
'j'),
'The given "j" was not found in the built request.');
234 $this->assertTrue(
$request->hasArgument(
'm'),
'The given "m" was not found in the built request.');
235 $this->assertSame(
$request->getArgument(
'testArgument'),
'value',
'The "testArgument" had not the given value.');
236 $this->assertSame(
$request->getArgument(
'testArgument2'),
'value2',
'The "testArgument2" had not the given value.');
237 $this->assertSame(
$request->getArgument(
'testArgument3'),
'value3',
'The "testArgument3" had not the given value.');
238 $this->assertSame(
$request->getArgument(
'testArgument4'),
'value4',
'The "testArgument4" had not the given value.');
239 $this->assertSame(
$request->getArgument(
'f'),
'valuef',
'The "f" had not the given value.');
240 $this->assertSame(
$request->getArgument(
'd'),
'valued',
'The "d" had not the given value.');
241 $this->assertSame(
$request->getArgument(
'a'),
'valuea',
'The "a" had not the given value.');
242 $this->assertSame(
$request->getArgument(
'testArgument5'),
'5',
'The "testArgument4" had not the given value.');
243 $this->assertSame(
$request->getArgument(
'j'),
'kjk',
'The "j" had not the given value.');
251 $methodParameters = array(
252 'testArgument1' => array(
'optional' => FALSE,
'type' =>
'string'),
253 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string')
255 $this->mockReflectionService->expects($this->exactly(2))->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
256 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument1 firstArgumentValue --test-argument2 secondArgumentValue');
257 $this->assertSame(
'firstArgumentValue',
$request->getArgument(
'testArgument1'));
258 $this->assertSame(
'secondArgumentValue',
$request->getArgument(
'testArgument2'));
259 $request = $this->requestBuilder->build(
'some_extension_name:default:list firstArgumentValue secondArgumentValue');
260 $this->assertSame(
'firstArgumentValue', $request->getArgument(
'testArgument1'));
261 $this->assertSame(
'secondArgumentValue', $request->getArgument(
'testArgument2'));
269 $methodParameters = array(
270 'some' => array(
'optional' => TRUE,
'type' =>
'boolean'),
271 'option' => array(
'optional' => TRUE,
'type' =>
'string'),
272 'argument1' => array(
'optional' => FALSE,
'type' =>
'string'),
273 'argument2' => array(
'optional' => FALSE,
'type' =>
'string')
275 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
276 $request = $this->requestBuilder->build(
'some_extension_name:default:list --some -option=value file1 file2');
277 $this->assertSame(
'list',
$request->getControllerCommandName());
278 $this->assertTrue(
$request->getArgument(
'some'));
279 $this->assertSame(
'file1',
$request->getArgument(
'argument1'));
280 $this->assertSame(
'file2',
$request->getArgument(
'argument2'));
288 $methodParameters = array(
289 'testArgument1' => array(
'optional' => FALSE,
'type' =>
'string'),
290 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string')
292 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
293 $expectedArguments = array(
'testArgument1' =>
'firstArgumentValue',
'testArgument2' =>
'secondArgumentValue');
294 $request = $this->requestBuilder->build(
'some_extension_name:default:list --test-argument1=firstArgumentValue --test-argument2 secondArgumentValue exceedingArgument1');
295 $this->assertEquals($expectedArguments,
$request->getArguments());
296 $this->assertEquals(array(
'exceedingArgument1'),
$request->getExceedingArguments());
305 $methodParameters = array(
306 'testArgument1' => array(
'optional' => FALSE,
'type' =>
'string'),
307 'testArgument2' => array(
'optional' => FALSE,
'type' =>
'string')
309 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
310 $this->requestBuilder->build(
'some_extension_name:default:list --test-argument1 firstArgumentValue secondArgumentValue');
319 $methodParameters = array(
320 'requiredArgument1' => array(
'optional' => FALSE,
'type' =>
'string'),
321 'requiredArgument2' => array(
'optional' => FALSE,
'type' =>
'string')
323 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
324 $this->requestBuilder->build(
'some_extension_name:default:list firstArgumentValue --required-argument2 secondArgumentValue');
332 $methodParameters = array(
333 'requiredArgument1' => array(
'optional' => FALSE,
'type' =>
'string'),
334 'requiredArgument2' => array(
'optional' => FALSE,
'type' =>
'string'),
335 'booleanOption' => array(
'optional' => TRUE,
'type' =>
'boolean')
337 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
338 $expectedArguments = array(
'requiredArgument1' =>
'firstArgumentValue',
'requiredArgument2' =>
'secondArgumentValue',
'booleanOption' => TRUE);
339 $request = $this->requestBuilder->build(
'some_extension_name:default:list --booleanOption firstArgumentValue secondArgumentValue');
340 $this->assertEquals($expectedArguments,
$request->getArguments());
348 $methodParameters = array(
349 'b1' => array(
'optional' => TRUE,
'type' =>
'boolean'),
350 'b2' => array(
'optional' => TRUE,
'type' =>
'boolean'),
351 'b3' => array(
'optional' => TRUE,
'type' =>
'boolean'),
352 'b4' => array(
'optional' => TRUE,
'type' =>
'boolean'),
353 'b5' => array(
'optional' => TRUE,
'type' =>
'boolean'),
354 'b6' => array(
'optional' => TRUE,
'type' =>
'boolean')
356 $this->mockReflectionService->expects($this->once())->method(
'getMethodParameters')->with(
'Tx_SomeExtensionName_Command_DefaultCommandController',
'listCommand')->will($this->returnValue($methodParameters));
357 $expectedArguments = array(
'b1' => TRUE,
'b2' => TRUE,
'b3' => TRUE,
'b4' => FALSE,
'b5' => FALSE,
'b6' => FALSE);
358 $request = $this->requestBuilder->build(
'some_extension_name:default:list --b2 y --b1 1 --b3 true --b4 false --b5 n --b6 0');
359 $this->assertEquals($expectedArguments,
$request->getArguments());
exceedingArgumentsMayBeSpecified()
booleanOptionsCanHaveOnlyCertainValuesIfTheValueIsAssignedWithoutEqualSign()
cliAccessWithExtensionControllerActionAndArgumentsBuildsCorrectRequest()
insteadOfNamedArgumentsTheArgumentsCanBePassedUnnamedInTheCorrectOrder()
ifCommandCantBeResolvedTheHelpScreenIsShown()
CLIAccesWithArgumentsWithAndWithoutValuesBuildsCorrectRequest()
ifNamedArgumentsAreUsedAllRequiredArgumentsMustBeNamed()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
ifUnnamedArgumentsAreUsedAllRequiredArgumentsMustBeUnnamed()
cliAccessWithExtensionControllerAndActionNameBuildsCorrectRequest()
$mockConfigurationManager
argumentWithValueSeparatedByEqualSignBuildsCorrectRequest()
CLIAccesWithShortArgumentsBuildsCorrectRequest()
checkIfCLIAccesWithPackageControllerActionAndArgumentsToleratesSpaces()
argumentsAreDetectedAfterOptions()
booleanOptionsAreConsideredEvenIfAnUnnamedArgumentFollows()