Detects and registers any validators for arguments:
- by the data type specified in the param annotations
- additional validators specified in the validate annotations of a method
public buildMethodArgumentsValidatorConjunctions ( string $className, string $methodName, array $methodParameters = null, array $methodValidateAnnotations = null ) : array | ||
$className | string | |
$methodName | string | |
$methodParameters | array | Optional pre-compiled array of method parameters |
$methodValidateAnnotations | array | Optional pre-compiled array of validate annotations (as array) |
return | array | An Array of ValidatorConjunctions for each method parameters. |
/** * @test */ public function buildMethodArgumentsValidatorConjunctionsReturnsEmptyArrayIfMethodHasNoArguments() { $mockController = $this->getAccessibleMock(ActionController::class, ['fooAction'], [], '', false); $mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock(); $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue([])); $this->validatorResolver = $this->getAccessibleMock(ValidatorResolver::class, ['createValidator'], [], '', false); $this->validatorResolver->_set('reflectionService', $mockReflectionService); $result = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction'); $this->assertSame([], $result); }