‪TYPO3CMS  10.4
ButtonViewHelperTest.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 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 
24 class ‪ButtonViewHelperTest extends ViewHelperBaseTestcase
25 {
29  protected ‪$viewHelper;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->viewHelper = new ‪ButtonViewHelper();
35  $this->injectDependenciesIntoViewHelper($this->viewHelper);
36  }
37 
42  {
43  $this->viewHelper->setRenderChildrenClosure(
44  function () {
45  return 'Button Content';
46  }
47  );
48 
49  $this->setArgumentsUnderTest(
50  $this->viewHelper,
51  [
52  'type' => 'submit'
53  ]
54  );
55 
56  $expectedResult = '<button type="submit" name="" value="">Button Content</button>';
57  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
58  self::assertEquals($expectedResult, $actualResult);
59  }
60 
64  public function ‪closingTagIsEnforcedOnEmptyContent(): void
65  {
66  $this->viewHelper->setRenderChildrenClosure(
67  function () {
68  // Empty content
69  return '';
70  }
71  );
72 
73  $this->setArgumentsUnderTest(
74  $this->viewHelper,
75  [
76  'type' => 'reset',
77  ]
78  );
79 
80  $expectedResult = '<button type="reset" name="" value=""></button>';
81  $actualResult = $this->viewHelper->initializeArgumentsAndRender();
82  self::assertEquals($expectedResult, $actualResult);
83  }
84 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\ButtonViewHelperTest\renderCorrectlySetsTagNameAndDefaultAttributes
‪renderCorrectlySetsTagNameAndDefaultAttributes()
Definition: ButtonViewHelperTest.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\ButtonViewHelperTest\setUp
‪setUp()
Definition: ButtonViewHelperTest.php:30
‪TYPO3\CMS\Fluid\ViewHelpers\Form\ButtonViewHelper
Definition: ButtonViewHelper.php:46
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\ButtonViewHelperTest
Definition: ButtonViewHelperTest.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form
Definition: AbstractFormFieldViewHelperTest.php:16
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\ButtonViewHelperTest\closingTagIsEnforcedOnEmptyContent
‪closingTagIsEnforcedOnEmptyContent()
Definition: ButtonViewHelperTest.php:63
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\ButtonViewHelperTest\$viewHelper
‪ButtonViewHelper $viewHelper
Definition: ButtonViewHelperTest.php:28