/** * @param ViewHelperInterface $viewHelper * @return void */ protected function injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper) { $viewHelper->_set('configurationManager', $this->mockConfigurationManager); parent::injectDependenciesIntoViewHelper($viewHelper); $hashService = $this->getMock(\TYPO3\CMS\Extbase\Security\Cryptography\HashService::class, array('appendHmac')); $hashService->expects($this->any())->method('appendHmac')->will($this->returnValue('')); $this->mvcPropertyMapperConfigurationService->_set('hashService', $hashService); $viewHelper->_set('mvcPropertyMapperConfigurationService', $this->mvcPropertyMapperConfigurationService); $viewHelper->_set('hashService', $hashService); }
/** * @param ArgumentDefinition[] $argumentDefinitions * @param NodeInterface[] $argumentsObjectTree * @throws Exception */ protected function validateArguments(array $argumentDefinitions, array $argumentsObjectTree) { $additionalArguments = []; foreach ($argumentsObjectTree as $argumentName => $value) { if (!array_key_exists($argumentName, $argumentDefinitions)) { $additionalArguments[$argumentName] = $value; } } foreach ($argumentDefinitions as $argumentDefinition) { if ($argumentDefinition->isRequired() && $argumentDefinition->getDefaultValue() === null) { $name = $argumentDefinition->getName(); if (!array_key_exists($name, $argumentsObjectTree)) { throw new Exception(sprintf('Required argument %s for ViewHelper %s was not provided', $name, $this->viewHelperClassName)); } } } $this->abortIfRequiredArgumentsAreMissing($argumentDefinitions, $argumentsObjectTree); $this->uninitializedViewHelper->validateAdditionalArguments($additionalArguments); }
/** * @return ArgumentDefinition[] */ public function getArgumentDefinitions() { return $this->uninitializedViewHelper->prepareArguments(); }
/** * Helper function to merge arguments with default arguments according to their registration * This usually happens in ViewHelperInvoker before the view helper methods are called * * @param ViewHelperInterface $viewHelper * @param array $arguments */ protected function setArgumentsUnderTest(ViewHelperInterface $viewHelper, array $arguments = []) { $argumentDefinitions = $viewHelper->prepareArguments(); foreach ($argumentDefinitions as $argumentName => $argumentDefinition) { if (!isset($arguments[$argumentName])) { $arguments[$argumentName] = $argumentDefinition->getDefaultValue(); } } $viewHelper->setArguments($arguments); }
/** * Return an array of ArgumentDefinition instances which describe * the arguments that the ViewHelper supports. By default, the * arguments are simply fetched from the ViewHelper - but custom * implementations can if necessary add/remove/replace arguments * which will be passed to the ViewHelper. * * @param ViewHelperInterface $viewHelper * @return ArgumentDefinition[] */ public function getArgumentDefinitionsForViewHelper(ViewHelperInterface $viewHelper) { return $viewHelper->prepareArguments(); }
/** * @param ViewHelperInterface $viewHelper * @return void */ protected function injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper) { $viewHelper->_set('configurationManager', $this->mockConfigurationManager); parent::injectDependenciesIntoViewHelper($viewHelper); }