‪TYPO3CMS  10.4
FormFieldViewHelperBaseTestcase.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 
18 use Prophecy\Argument;
21 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface;
23 
27 abstract class ‪FormFieldViewHelperBaseTestcase extends ViewHelperBaseTestcase
28 {
33 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->mockConfigurationManager = $this->createMock(ConfigurationManagerInterface::class);
38  }
39 
43  protected function ‪injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
44  {
45  $viewHelper->injectConfigurationManager($this->mockConfigurationManager);
46  parent::injectDependenciesIntoViewHelper($viewHelper);
47  }
48 
52  protected function ‪stubRequestWithoutMappingErrors()
53  {
54  $this->request->getOriginalRequest()->willReturn(null);
55  $this->request->getArguments()->willReturn([]);
56  $result = $this->prophesize(Result::class);
57  $result->forProperty('objectName')->willReturn($result->reveal());
58  $result->forProperty('someProperty')->willReturn($result->reveal());
59  $result->hasErrors()->willReturn(false);
60  $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
61  }
62 
66  protected function ‪stubRequestWithMappingErrors()
67  {
68  $this->request->getOriginalRequest()->willReturn(null);
69  $this->request->getArguments()->willReturn([]);
70  $result = $this->prophesize(Result::class);
71  $result->forProperty('objectName')->willReturn($result->reveal());
72  $result->forProperty('someProperty')->willReturn($result->reveal());
73  $result->hasErrors()->willReturn(true);
74  $this->request->getOriginalRequestMappingResults()->willReturn($result->reveal());
75  }
76 
82  protected function ‪stubVariableContainer($formObject)
83  {
84  $this->viewHelperVariableContainer->exists(Argument::cetera())->willReturn(true);
85  $this->viewHelperVariableContainer->get(
86  Argument::any(),
87  'formObjectName'
88  )->willReturn('objectName');
89  $this->viewHelperVariableContainer->get(
90  Argument::any(),
91  'fieldNamePrefix'
92  )->willReturn('fieldPrefix');
93  $this->viewHelperVariableContainer->get(Argument::any(), 'formFieldNames')->willReturn([]);
94  $this->viewHelperVariableContainer->get(
95  Argument::any(),
96  'formObject'
97  )->willReturn($formObject);
98  $this->viewHelperVariableContainer->get(
99  Argument::any(),
100  'renderedHiddenFields'
101  )->willReturn([]);
102  $this->viewHelperVariableContainer->addOrUpdate(Argument::cetera())->willReturn(null);
103  }
104 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\$mockConfigurationManager
‪ConfigurationManagerInterface $mockConfigurationManager
Definition: FormFieldViewHelperBaseTestcase.php:31
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\setUp
‪setUp()
Definition: FormFieldViewHelperBaseTestcase.php:33
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\injectDependenciesIntoViewHelper
‪injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
Definition: FormFieldViewHelperBaseTestcase.php:42
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase
Definition: FormFieldViewHelperBaseTestcase.php:28
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Error\Result
Definition: Result.php:24
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form
Definition: AbstractFormFieldViewHelperTest.php:16
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\stubRequestWithMappingErrors
‪stubRequestWithMappingErrors()
Definition: FormFieldViewHelperBaseTestcase.php:65
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\stubVariableContainer
‪stubVariableContainer($formObject)
Definition: FormFieldViewHelperBaseTestcase.php:81
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase\stubRequestWithoutMappingErrors
‪stubRequestWithoutMappingErrors()
Definition: FormFieldViewHelperBaseTestcase.php:51