/**
  * @test
  * @dataProvider renderDataProvider()
  * @param string $expectedResult
  * @param array $flashMessages
  * @param string $class
  * @return void
  */
 public function renderTests($expectedResult, array $flashMessages = array(), $class = NULL)
 {
     $this->mockFlashMessageContainer->expects($this->once())->method('getMessagesAndFlush')->will($this->returnValue($flashMessages));
     $this->mockTagBuilder->expects($this->once())->method('setContent')->with($expectedResult);
     if ($class !== NULL) {
         $this->viewHelper->_set('arguments', array('class' => $class));
     }
     $this->viewHelper->render();
 }
Exemplo n.º 2
0
 /**
  * Renders hidden form fields for referrer information about
  * the current request.
  *
  * @return string Hidden fields with referrer information
  */
 protected function renderHiddenReferrerFields()
 {
     $tagBuilder = new TagBuilder('input');
     $tagBuilder->addAttribute('type', 'hidden');
     $tagBuilder->addAttribute('name', $this->prefixFieldName('__state'));
     $serializedFormState = base64_encode(serialize($this->arguments['object']->getFormState()));
     $tagBuilder->addAttribute('value', $this->hashService->appendHmac($serializedFormState));
     return $tagBuilder->render();
 }
Exemplo n.º 3
0
 /**
  * Sets the tag name to $this->tagName.
  * Additionally, sets all tag attributes which were registered in
  * $this->tagAttributes and additionalArguments.
  *
  * Will be invoked just before the render method.
  *
  * @return void
  * @api
  */
 public function initialize()
 {
     parent::initialize();
     $this->tag->reset();
     $this->tag->setTagName($this->tagName);
     if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) {
         $this->tag->addAttributes($this->arguments['additionalAttributes']);
     }
     if (isset(self::$tagAttributes[get_class($this)])) {
         foreach (self::$tagAttributes[get_class($this)] as $attributeName) {
             if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') {
                 $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]);
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function thumbnailHeightMightExceedImageHeightIfAllowUpScalingIsTrue()
 {
     $this->mockTagBuilder->expects($this->once())->method('render');
     $this->mockTagBuilder->expects($this->once())->method('addAttributes')->with(array('width' => null, 'height' => 456, 'src' => null));
     $this->mockImage->expects($this->once())->method('getThumbnail')->with(100, 456, 'inset')->will($this->returnValue($this->mockThumbnail));
     $this->viewHelper->render($this->mockImage, NULL, 456, FALSE, TRUE);
 }
Exemplo n.º 5
0
 /**
  * Renders the captcha image and its textfields
  *
  * @return string
  */
 public function render()
 {
     // Render image tag
     $this->tag->reset();
     $this->tag->setTagName("img");
     $this->tag->addAttributes($this->getAttributes("image", array("src" => $this->captchaService->create($this->arguments["width"], $this->arguments["height"]), "width" => $this->arguments["width"], "height" => $this->arguments["height"], "style" => "width: " . $this->arguments["width"] . "px; height: " . $this->arguments["height"] . "px;")));
     $markup = str_replace("{image}", $this->tag->render(), $this->arguments["markup"]);
     // Render phrase textfield
     $this->tag->reset();
     $this->tag->setTagName("input");
     $this->tag->addAttributes($this->getAttributes("phrase", array("name" => $this->arguments["name"] . "[phrase]", "type" => "text", "autocomplete" => "off")));
     $markup = str_replace("{phrase}", $this->tag->render(), $markup);
     // Render phrase textfield
     $this->tag->reset();
     $this->tag->setTagName("input");
     $this->tag->addAttributes($this->getAttributes("hash", array("name" => $this->arguments["name"] . "[hash]", "type" => "hidden", "value" => $this->captchaService->getPhraseHash())));
     return str_replace("{hash}", $this->tag->render(), $markup);
 }
 /**
  * @test
  */
 public function callingRenderReturnsTagBuildersRenderResult()
 {
     $this->tagBuilder->expects($this->once())->method('render')->will($this->returnValue('renderingResult'));
     $this->assertSame('renderingResult', $this->viewHelper->render('path'));
 }
 /**
  * Prepend a script tag with property metadata to the content
  *
  * @param \TYPO3\Fluid\Core\ViewHelper\TagBuilder $tagBuilder
  * @param string $propertyName
  * @param string $propertyValue
  * @param string $dataType
  * @return void
  */
 protected function addScriptTag(\TYPO3\Fluid\Core\ViewHelper\TagBuilder $tagBuilder, $propertyName, $propertyValue, $dataType = 'string')
 {
     $dataType = $this->getDataTypeCurie($dataType);
     if ($dataType === 'xsd:string') {
         $dataTypeAttribute = '';
     } else {
         $dataTypeAttribute = sprintf(' datatype="%s"', $dataType);
     }
     $tag = sprintf('<script type="text/x-typo3" property="typo3:%s"%s>%s</script>', $propertyName, $dataTypeAttribute, $propertyValue);
     $tagBuilder->setContent($tag . $tagBuilder->getContent());
 }