‪TYPO3CMS  9.5
HiddenViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
19 
24 {
28  protected ‪$viewHelper;
29 
30  protected function ‪setUp()
31  {
32  parent::setUp();
33  $this->viewHelper = $this->getAccessibleMock(HiddenViewHelper::class, ['setErrorClassAttribute', 'getName', 'getValueAttribute', 'registerFieldNameForFormTokenGeneration']);
34  $this->‪injectDependenciesIntoViewHelper($this->viewHelper);
35  }
36 
41  {
42  $tagBuilder = $this->prophesize(TagBuilder::class);
43  $tagBuilder->render()->shouldBeCalled();
44  // @todo remove condition once typo3fluid/fluid version 2.6.0 will be the minimum version
45  if (class_exists(\‪TYPO3Fluid\Fluid\ViewHelpers\InlineViewHelper::class)) {
46  $tagBuilder->reset()->shouldBeCalled();
47  }
48  $tagBuilder->addAttribute('type', 'hidden')->shouldBeCalled();
49  $tagBuilder->addAttribute('name', 'foo')->shouldBeCalled();
50  $tagBuilder->addAttribute('value', 'bar')->shouldBeCalled();
51  $tagBuilder->setTagName('input')->shouldBeCalled();
52  $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
53 
54  $this->viewHelper->expects($this->once())->method('getName')->will($this->returnValue('foo'));
55  $this->viewHelper->expects($this->once())->method('getValueAttribute')->will($this->returnValue('bar'));
56  $this->viewHelper->setTagBuilder($tagBuilder->reveal());
57 
58  $this->viewHelper->initializeArgumentsAndRender();
59  }
60 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\HiddenViewHelperTest
Definition: HiddenViewHelperTest.php:24
‪TYPO3Fluid
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\injectDependenciesIntoViewHelper
‪injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
Definition: FormFieldViewHelperBaseTestcase.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
Definition: FormFieldViewHelperBaseTestcase.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\HiddenViewHelperTest\renderCorrectlySetsTagNameAndDefaultAttributes
‪renderCorrectlySetsTagNameAndDefaultAttributes()
Definition: HiddenViewHelperTest.php:39
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form
Definition: AbstractFormFieldViewHelperTest.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper
Definition: HiddenViewHelper.php:35
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\HiddenViewHelperTest\setUp
‪setUp()
Definition: HiddenViewHelperTest.php:29
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\HiddenViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Form HiddenViewHelper $viewHelper
Definition: HiddenViewHelperTest.php:27