[!!!][TASK] Remove CMS base ViewHelper classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / Form / HiddenViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
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 use TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper;
17 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
18
19 /**
20 * Test for the "Hidden" Form view helper
21 */
22 class HiddenViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
23 {
24 /**
25 * @var \TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper
26 */
27 protected $viewHelper;
28
29 protected function setUp()
30 {
31 parent::setUp();
32 $this->viewHelper = $this->getAccessibleMock(HiddenViewHelper::class, ['setErrorClassAttribute', 'getName', 'getValueAttribute', 'registerFieldNameForFormTokenGeneration']);
33 $this->injectDependenciesIntoViewHelper($this->viewHelper);
34 }
35
36 /**
37 * @test
38 */
39 public function renderCorrectlySetsTagNameAndDefaultAttributes()
40 {
41 $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
42 ->setMethods(['setTagName', 'addAttribute'])
43 ->getMock();
44 $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
45 $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'hidden');
46 $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
47 $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
48 $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
49
50 $this->viewHelper->expects($this->once())->method('getName')->will($this->returnValue('foo'));
51 $this->viewHelper->expects($this->once())->method('getValueAttribute')->will($this->returnValue('bar'));
52 $this->viewHelper->setTagBuilder($mockTagBuilder);
53
54 $this->viewHelper->initializeArgumentsAndRender();
55 }
56 }