‪TYPO3CMS  11.5
FormTestService.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 
29 {
37  public function ‪createNewRecordForm(string $table, array $defaults = []): array
38  {
39  $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
40  $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
41  $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
42 
43  $formDataCompilerInput = [
44  'tableName' => $table,
45  'vanillaUid' => 0,
46  'command' => 'new',
47  'databaseRow' => $defaults,
48  ];
49  $formData = $formDataCompiler->compile($formDataCompilerInput);
50 
51  $formData['renderType'] = 'outerWrapContainer';
52  return $nodeFactory->create($formData)->render();
53  }
54 
62  public function ‪formHtmlContainsField(string $fieldName, string $formHtml): bool
63  {
64  return (bool)strpos($formHtml, '[' . $fieldName . ']');
65  }
66 }
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService\createNewRecordForm
‪array createNewRecordForm(string $table, array $defaults=[])
Definition: FormTestService.php:37
‪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:62
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:29
‪TYPO3\CMS\Backend\Tests\Functional\Form
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Form\FormDataCompiler
Definition: FormDataCompiler.php:25
‪TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord
Definition: TcaDatabaseRecord.php:25