‪TYPO3CMS  10.4
PasswordViewHelperTest.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 
20 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
21 
26 {
30  protected ‪$viewHelper;
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35  $this->viewHelper = $this->getAccessibleMock(PasswordViewHelper::class, ['setErrorClassAttribute', 'registerFieldNameForFormTokenGeneration']);
36  $this->arguments['name'] = '';
37  $this->‪injectDependenciesIntoViewHelper($this->viewHelper);
38  }
39 
43  public function ‪renderCorrectlySetsTagName()
44  {
45  $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
46  ->setMethods(['setTagName'])
47  ->disableOriginalConstructor()
48  ->getMock();
49  $mockTagBuilder->expects(self::atLeastOnce())->method('setTagName')->with('input');
50  $this->viewHelper->setTagBuilder($mockTagBuilder);
51  $this->viewHelper->initializeArgumentsAndRender();
52  }
53 
58  {
59  $mockTagBuilder = $this->getMockBuilder(TagBuilder::class)
60  ->setMethods(['addAttribute', 'setContent', 'render'])
61  ->disableOriginalConstructor()
62  ->getMock();
63  $mockTagBuilder->expects(self::exactly(3))->method('addAttribute')->withConsecutive(
64  ['type', 'password'],
65  ['name', 'NameOfTextbox'],
66  ['value', 'Current value']
67  );
68  $this->viewHelper->expects(self::once())->method('registerFieldNameForFormTokenGeneration')->with('NameOfTextbox');
69  $mockTagBuilder->expects(self::once())->method('render');
70  $this->viewHelper->setTagBuilder($mockTagBuilder);
71 
72  $arguments = [
73  'name' => 'NameOfTextbox',
74  'value' => 'Current value'
75  ];
76  $this->viewHelper->setArguments($arguments);
77 
78  $this->viewHelper->setViewHelperNode(new EmptySyntaxTreeNode());
79  $this->viewHelper->initializeArgumentsAndRender();
80  }
81 
85  public function ‪renderCallsSetErrorClassAttribute()
86  {
87  $this->viewHelper->expects(self::once())->method('setErrorClassAttribute');
88  $this->viewHelper->render();
89  }
90 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCorrectlySetsTagName
‪renderCorrectlySetsTagName()
Definition: PasswordViewHelperTest.php:42
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\injectDependenciesIntoViewHelper
‪injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
Definition: FormFieldViewHelperBaseTestcase.php:42
‪TYPO3\CMS\Fluid\ViewHelpers\Form\PasswordViewHelper
Definition: PasswordViewHelper.php:33
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
Definition: FormFieldViewHelperBaseTestcase.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCallsSetErrorClassAttribute
‪renderCallsSetErrorClassAttribute()
Definition: PasswordViewHelperTest.php:84
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode
Definition: EmptySyntaxTreeNode.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form
Definition: AbstractFormFieldViewHelperTest.php:16
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Form PasswordViewHelper $viewHelper
Definition: PasswordViewHelperTest.php:29
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\setUp
‪setUp()
Definition: PasswordViewHelperTest.php:31
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest
Definition: PasswordViewHelperTest.php:26
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\PasswordViewHelperTest\renderCorrectlySetsTypeNameAndValueAttributes
‪renderCorrectlySetsTypeNameAndValueAttributes()
Definition: PasswordViewHelperTest.php:56