[BUGFIX] Submitted form data has precedence over value argument
[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 script is backported from the FLOW3 package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 use TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper;
15
16 /**
17 * Test for the "Hidden" Form view helper
18 */
19 class HiddenViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase {
20
21 /**
22 * @var \TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper
23 */
24 protected $viewHelper;
25
26 protected function setUp() {
27 parent::setUp();
28 $this->viewHelper = $this->getAccessibleMock(HiddenViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValueAttribute', 'registerFieldNameForFormTokenGeneration'));
29 $this->injectDependenciesIntoViewHelper($this->viewHelper);
30 $this->viewHelper->initializeArguments();
31 }
32
33 /**
34 * @test
35 */
36 public function renderCorrectlySetsTagNameAndDefaultAttributes() {
37 $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute'));
38 $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
39 $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'hidden');
40 $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
41 $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
42 $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
43
44 $this->viewHelper->expects($this->once())->method('getName')->will($this->returnValue('foo'));
45 $this->viewHelper->expects($this->once())->method('getValueAttribute')->will($this->returnValue('bar'));
46 $this->viewHelper->_set('tag', $mockTagBuilder);
47
48 $this->viewHelper->initialize();
49 $this->viewHelper->render();
50 }
51
52 }