‪TYPO3CMS  9.5
PasswordViewHelperTest.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 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
17 
22 {
26  protected ‪$viewHelper;
27 
28  protected function ‪setUp()
29  {
30  parent::setUp();
31  $this->viewHelper = $this->getAccessibleMock(\‪TYPO3\CMS\Fluid\ViewHelpers\Form\PasswordViewHelper::class, ['setErrorClassAttribute', 'registerFieldNameForFormTokenGeneration']);
32  $this->arguments['name'] = '';
33  $this->‪injectDependenciesIntoViewHelper($this->viewHelper);
34  }
35 
39  public function ‪renderCorrectlySetsTagName()
40  {
41  $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
42  ->setMethods(['setTagName'])
43  ->disableOriginalConstructor()
44  ->getMock();
45  $mockTagBuilder->expects($this->atLeastOnce())->method('setTagName')->with('input');
46  $this->viewHelper->setTagBuilder($mockTagBuilder);
47  $this->viewHelper->initializeArgumentsAndRender();
48  }
49 
54  {
55  $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
56  ->setMethods(['addAttribute', 'setContent', 'render'])
57  ->disableOriginalConstructor()
58  ->getMock();
59  $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('type', 'password');
60  $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'NameOfTextbox');
61  $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('NameOfTextbox');
62  $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('value', 'Current value');
63  $mockTagBuilder->expects($this->once())->method('render');
64  $this->viewHelper->setTagBuilder($mockTagBuilder);
65 
66  $arguments = [
67  'name' => 'NameOfTextbox',
68  'value' => 'Current value'
69  ];
70  $this->viewHelper->setArguments($arguments);
71 
72  $this->viewHelper->setViewHelperNode(new \‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
73  $this->viewHelper->initializeArgumentsAndRender();
74  }
75 
79  public function ‪renderCallsSetErrorClassAttribute()
80  {
81  $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
82  $this->viewHelper->render();
83  }
84 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCorrectlySetsTagName
‪renderCorrectlySetsTagName()
Definition: PasswordViewHelperTest.php:38
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\injectDependenciesIntoViewHelper
‪injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
Definition: FormFieldViewHelperBaseTestcase.php:40
‪TYPO3
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
Definition: FormFieldViewHelperBaseTestcase.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCallsSetErrorClassAttribute
‪renderCallsSetErrorClassAttribute()
Definition: PasswordViewHelperTest.php:78
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode
Definition: EmptySyntaxTreeNode.php:21
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form
Definition: AbstractFormFieldViewHelperTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Form PasswordViewHelper $viewHelper
Definition: PasswordViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\setUp
‪setUp()
Definition: PasswordViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest
Definition: PasswordViewHelperTest.php:22
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCorrectlySetsTypeNameAndValueAttributes
‪renderCorrectlySetsTypeNameAndValueAttributes()
Definition: PasswordViewHelperTest.php:52