/** * @test */ public function renderSetsAttributeNameAsArrayIfMultipleIsGiven() { /** @var \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder $tagBuilder */ $tagBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class); $tagBuilder->addAttribute('multiple', 'multiple'); $this->viewHelper->_set('tag', $tagBuilder); $arguments = array('name' => 'someName', 'multiple' => 'multiple'); $this->viewHelper->setArguments($arguments); $this->viewHelper->initialize(); $result = $this->viewHelper->render(); $this->assertEquals('<input multiple="multiple" type="file" name="someName[]" />', $result); }
/** * Renders the upload field with possible resource pointer * * @return string * @api */ public function render() { $output = ''; $resource = $this->getUploadedResource(); if ($resource !== NULL) { $resourcePointerIdAttribute = ''; if ($this->hasArgument('id')) { $resourcePointerIdAttribute = ' id="' . htmlspecialchars($this->arguments['id']) . '-file-reference"'; } $resourcePointerValue = $resource->getUid(); if ($resourcePointerValue === NULL) { // Newly created file reference which is not persisted yet. // Use the file UID instead, but prefix it with "file:" to communicate this to the type converter $resourcePointerValue = 'file:' . $resource->getOriginalResource()->getOriginalFile()->getUid(); } $output .= '<input type="hidden" name="' . $this->getName() . '[submittedFile][resourcePointer]" value="' . htmlspecialchars($this->hashService->appendHmac((string) $resourcePointerValue)) . '"' . $resourcePointerIdAttribute . ' />'; } $output .= parent::render(); $this->templateVariableContainer->add('resource', $resource); $this->templateVariableContainer->add('property', $this->arguments['property']); $output .= $this->renderChildren(); $this->templateVariableContainer->remove('resource'); $this->templateVariableContainer->remove('property'); return $output; }
/** * @test */ public function renderCallsSetErrorClassAttribute() { $this->viewHelper->expects($this->once())->method('setErrorClassAttribute'); $this->viewHelper->render(); }