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