‪TYPO3CMS  ‪main
TcaGroupTest.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 
20 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 final class ‪TcaGroupTest extends FunctionalTestCase
26 {
27  protected array ‪$coreExtensionsToLoad = ['workspaces'];
28 
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users.csv');
33  $backendUser = $this->setUpBackendUser(1);
34  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
35 
36  $this->importCSVDataSet(__DIR__ . '/../Fixtures/TcaGroup.csv');
37  }
38 
42  #[Test]
43  public function ‪respectsDeletedElements()
44  {
45  $aFieldConfig = [
46  'type' => 'group',
47  'allowed' => 'pages',
48  'maxitems' => 99999,
49  ];
50  $input = [
51  'tableName' => 'aTable',
52  'databaseRow' => [
53  'uid' => 42,
54  'aField' => '1,2,3,4',
55  ],
56  'processedTca' => [
57  'columns' => [
58  'aField' => [
59  'config' => $aFieldConfig,
60  ],
61  ],
62  ],
63  ];
64 
65  $result = (new ‪TcaGroup())->addData($input);
66  self::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items');
67 
68  $loadedUids = array_column($result['databaseRow']['aField'], 'uid');
69  self::assertEquals($loadedUids, [1, 3, 4], 'TcaGroup did not load the correct items');
70  }
71 
75  #[Test]
77  {
78  $aFieldConfig = [
79  'type' => 'group',
80  'allowed' => 'pages',
81  'maxitems' => 99999,
82  ];
83  $input = [
84  'tableName' => 'aTable',
85  'databaseRow' => [
86  'uid' => 42,
87  'aField' => '1,2,3,4',
88  ],
89  'processedTca' => [
90  'columns' => [
91  'aField' => [
92  'config' => $aFieldConfig,
93  ],
94  ],
95  ],
96  ];
97 
98  ‪$GLOBALS['BE_USER']->workspace = 1;
99 
100  $result = (new ‪TcaGroup())->addData($input);
101  self::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items in a workspace');
102 
103  $loadedUids = array_column($result['databaseRow']['aField'], 'uid');
104  self::assertEquals($loadedUids, [3, 4], 'TcaGroup did not load the correct items in a workspace');
105  }
106 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup
Definition: TcaGroup.php:29
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\setUp
‪setUp()
Definition: TcaGroupTest.php:29
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\respectsDeletedElements
‪respectsDeletedElements()
Definition: TcaGroupTest.php:43
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest
Definition: TcaGroupTest.php:26
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\respectsDeletedElementsInWorkspace
‪respectsDeletedElementsInWorkspace()
Definition: TcaGroupTest.php:76
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: TcaGroupTest.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider
Definition: TcaCategoryTest.php:18