TYPO3 CMS  TYPO3_7-6
HiddenViewHelperTest.php
Go to the documentation of this file.
1 <?php
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 
15 
20 {
24  protected $viewHelper;
25 
26  protected function setUp()
27  {
28  parent::setUp();
29  $this->viewHelper = $this->getAccessibleMock(HiddenViewHelper::class, ['setErrorClassAttribute', 'getName', 'getValueAttribute', 'registerFieldNameForFormTokenGeneration']);
30  $this->injectDependenciesIntoViewHelper($this->viewHelper);
31  $this->viewHelper->initializeArguments();
32  }
33 
38  {
39  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['setTagName', 'addAttribute']);
40  $mockTagBuilder->expects($this->once())->method('setTagName')->with('input');
41  $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'hidden');
42  $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo');
43  $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('foo');
44  $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
45 
46  $this->viewHelper->expects($this->once())->method('getName')->will($this->returnValue('foo'));
47  $this->viewHelper->expects($this->once())->method('getValueAttribute')->will($this->returnValue('bar'));
48  $this->viewHelper->_set('tag', $mockTagBuilder);
49 
50  $this->viewHelper->initialize();
51  $this->viewHelper->render();
52  }
53 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)