48 $this->command = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', array(
'getCommandMethodReflection'), array(),
'', FALSE);
49 $this->mockMethodReflection = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\MethodReflection', array(), array(),
'', FALSE);
50 $this->command->expects($this->any())->method(
'getCommandMethodReflection')->will($this->returnValue($this->mockMethodReflection));
51 $this->mockObjectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
52 $this->command->_set(
'objectManager', $this->mockObjectManager);
61 array(
'Tx_ExtensionKey_Command_CacheCommandController',
'flush',
'extension_key:cache:flush'),
62 array(
'Tx_Ext_Command_CookieCommandController',
'bake',
'ext:cookie:bake')
76 $this->assertEquals($expectedCommandIdentifier,
$command->getCommandIdentifier());
86 array(
'Tx_OtherExtensionKey_Foo_Faa_Fuuum_Command_CoffeeCommandController'),
107 $this->mockMethodReflection->expects($this->atLeastOnce())->method(
'getParameters')->will($this->returnValue(array()));
108 $this->assertFalse($this->command->hasArguments());
116 $mockParameterReflection = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ParameterReflection', array(), array(),
'', FALSE);
117 $this->mockMethodReflection->expects($this->atLeastOnce())->method(
'getParameters')->will($this->returnValue(array($mockParameterReflection)));
118 $this->assertTrue($this->command->hasArguments());
126 $this->mockMethodReflection->expects($this->atLeastOnce())->method(
'getParameters')->will($this->returnValue(array()));
127 $this->assertSame(array(), $this->command->getArgumentDefinitions());
135 $mockParameterReflection = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ParameterReflection', array(), array(),
'', FALSE);
136 $mockReflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
137 $mockMethodParameters = array(
'argument1' => array(
'optional' => FALSE),
'argument2' => array(
'optional' => TRUE));
138 $mockReflectionService->expects($this->atLeastOnce())->method(
'getMethodParameters')->will($this->returnValue($mockMethodParameters));
139 $this->command->_set(
'reflectionService', $mockReflectionService);
140 $this->mockMethodReflection->expects($this->atLeastOnce())->method(
'getParameters')->will($this->returnValue(array($mockParameterReflection)));
141 $this->mockMethodReflection->expects($this->atLeastOnce())->method(
'getTagsValues')->will($this->returnValue(array(
'param' => array(
'@param $argument1 argument1 description',
'@param $argument2 argument2 description'))));
142 $mockCommandArgumentDefinition1 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandArgumentDefinition', array(), array(),
'', FALSE);
143 $mockCommandArgumentDefinition2 = $this->getMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandArgumentDefinition', array(), array(),
'', FALSE);
144 $this->mockObjectManager->expects($this->at(0))->method(
'get')->with(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandArgumentDefinition',
'argument1', TRUE,
'argument1 description')->will($this->returnValue($mockCommandArgumentDefinition1));
145 $this->mockObjectManager->expects($this->at(1))->method(
'get')->with(
'TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandArgumentDefinition',
'argument2', FALSE,
'argument2 description')->will($this->returnValue($mockCommandArgumentDefinition2));
146 $expectedResult = array($mockCommandArgumentDefinition1, $mockCommandArgumentDefinition2);
147 $actualResult = $this->command->getArgumentDefinitions();
148 $this->assertSame($expectedResult, $actualResult);
hasArgumentsReturnsTrueIfCommandExpectsArguments()
getArgumentDefinitionsReturnsArrayOfArgumentDefinitionIfCommandExpectsArguments()
constructRendersACommandIdentifierByTheGivenControllerAndCommandName($controllerClassName, $commandName, $expectedCommandIdentifier)
constructThrowsExceptionIfCommandClassNameIsInvalid($controllerClassName)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
hasArgumentsReturnsFalseIfCommandExpectsNoArguments()
getArgumentDefinitionsReturnsEmptyArrayIfCommandExpectsNoArguments()
invalidCommandClassNames()