‪TYPO3CMS  10.4
FormTestService.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 
22 
27 {
35  public function ‪createNewRecordForm(string $table, array $defaults = [])
36  {
37  $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
38  $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
39  $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
40 
41  $formDataCompilerInput = [
42  'tableName' => $table,
43  'vanillaUid' => 0,
44  'command' => 'new',
45  'databaseRow' => $defaults
46  ];
47  $formData = $formDataCompiler->compile($formDataCompilerInput);
48 
49  $formData['renderType'] = 'outerWrapContainer';
50  return $nodeFactory->create($formData)->render();
51  }
52 
60  public function ‪formHtmlContainsField(string $fieldName, string $formHtml): bool
61  {
62  return strpos($formHtml, '[' . $fieldName . ']');
63  }
64 }
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService\createNewRecordForm
‪array createNewRecordForm(string $table, array $defaults=[])
Definition: FormTestService.php:35
‪TYPO3\CMS\Backend\Form\NodeFactory
Definition: NodeFactory.php:37
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService\formHtmlContainsField
‪bool formHtmlContainsField(string $fieldName, string $formHtml)
Definition: FormTestService.php:60
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:27
‪TYPO3\CMS\Backend\Tests\Functional\Form
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Form\FormDataCompiler
Definition: FormDataCompiler.php:25
‪TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord
Definition: TcaDatabaseRecord.php:25