[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / sys_action / Tests / Functional / Tca / ActionVisibleFieldsTest.php
1 <?php
2 namespace TYPO3\CMS\SysAction\Tests\Functional\Tca;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Lang\LanguageService;
20
21 class ActionVisibleFieldsTest extends \TYPO3\CMS\Components\TestingFramework\Core\FunctionalTestCase
22 {
23 protected $coreExtensionsToLoad = ['sys_action'];
24
25 protected static $actionCommonFields = [
26 'type',
27 'title',
28 'description',
29 'hidden',
30 'assign_to_groups',
31 ];
32
33 protected static $actionFieldsByType = [
34 '0' => [],
35 '1' => [
36 't1_userprefix',
37 't1_copy_of_user',
38 't1_allowed_groups',
39 't1_create_user_dir',
40 ],
41 '2' => [],
42 '3' => [
43 't3_listPid',
44 't3_tables',
45 ],
46 '4' => [
47 't4_recordsToEdit',
48 ],
49 '5' => [
50 't3_listPid',
51 't3_tables',
52 ],
53 ];
54
55 /**
56 * @test
57 */
58 public function actionFormContainsExpectedFields()
59 {
60 $this->setUpBackendUserFromFixture(1);
61 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
62
63 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
64
65 foreach (static::$actionFieldsByType as $type => $additionalFields) {
66 $expectedFields = array_merge(static::$actionCommonFields, $additionalFields);
67 $formResult = $formEngineTestService->createNewRecordForm('sys_action', ['type' => $type]);
68
69 foreach ($expectedFields as $expectedField) {
70 $this->assertNotFalse(
71 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
72 'The field ' . $expectedField . ' is not in the form HTML'
73 );
74 }
75 }
76 }
77 }