/** * @test */ public function buildMethodArgumentsValidatorConjunctionsReturnsEmptyArrayIfMethodHasNoArguments() { $mockController = $this->getAccessibleMock('TYPO3\\Flow\\Mvc\\Controller\\ActionController', array('fooAction'), array(), '', FALSE); $mockReflectionService = $this->getMock('TYPO3\\Flow\\Reflection\\ReflectionService', array(), array(), '', FALSE); $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue(array())); $this->validatorResolver = $this->getAccessibleMock('TYPO3\\Flow\\Validation\\ValidatorResolver', array('createValidator'), array(), '', FALSE); $this->validatorResolver->_set('reflectionService', $mockReflectionService); $result = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction'); $this->assertSame(array(), $result); }
/** * @test */ public function buildMethodArgumentsValidatorConjunctionsReturnsEmptyArrayIfMethodHasNoArguments() { $mockController = $this->getAccessibleMock(\TYPO3\Flow\Mvc\Controller\ActionController::class, array('fooAction'), array(), '', false); $mockReflectionService = $this->getMockBuilder(\TYPO3\Flow\Reflection\ReflectionService::class)->disableOriginalConstructor()->getMock(); $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue(array())); $this->validatorResolver = $this->getAccessibleMock(\TYPO3\Flow\Validation\ValidatorResolver::class, array('createValidator'), array(), '', false); $this->validatorResolver->_set('reflectionService', $mockReflectionService); $result = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction'); $this->assertSame(array(), $result); }
/** * intialize the arguments * */ protected function initializeArguments() { $methodParameters = $this->reflectionService->getMethodParameters($this->class, $this->method); $validators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions($this->class, $this->method); $validationGroups = array('Default', ucfirst($this->method)); foreach ($methodParameters as $name => $methodParameter) { $methodParameterType = $methodParameter['type'] == 'mixed' ? 'string' : $methodParameter['type']; $validator = $validators[$name]; $validator->addValidator($this->validatorResolver->getBaseValidatorConjunction($methodParameterType, $validationGroups)); $argument = new WebserviceCallArgument($name, $methodParameterType); $argument->setPosition($methodParameter['position']); $argument->setRequired(!$methodParameter['optional']); $argument->setDefaultValue($methodParameter['defaultValue']); $argument->setValidator($validator); $this->arguments[$name] = $argument; } }