‪TYPO3CMS  10.4
TcaGroupTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 /*
8  * This file is part of the TYPO3 CMS project.
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
27 class ‪TcaGroupTest extends FunctionalTestCase
28 {
29  protected ‪$coreExtensionsToLoad = ['workspaces'];
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->setUpBackendUserFromFixture(1);
36 
37  $this->importDataSet(__DIR__ . '/../Fixtures/TcaGroup.xml');
38  }
39 
45  public function ‪respectsDeletedElements()
46  {
47  $aFieldConfig = [
48  'type' => 'group',
49  'internal_type' => 'db',
50  'allowed' => 'pages',
51  'maxitems' => 99999,
52  ];
53  $input = [
54  'tableName' => 'aTable',
55  'databaseRow' => [
56  'uid' => 42,
57  'aField' => '1,2,3,4',
58  ],
59  'processedTca' => [
60  'columns' => [
61  'aField' => [
62  'config' => $aFieldConfig,
63  ],
64  ],
65  ],
66  ];
67 
68  $result = (new ‪TcaGroup())->addData($input);
69  self::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items');
70 
71  $loadedUids = array_column($result['databaseRow']['aField'], 'uid');
72  self::assertEquals($loadedUids, [1, 3, 4], 'TcaGroup did not load the correct items');
73  }
74 
81  {
82  $aFieldConfig = [
83  'type' => 'group',
84  'internal_type' => 'db',
85  'allowed' => 'pages',
86  'maxitems' => 99999,
87  ];
88  $input = [
89  'tableName' => 'aTable',
90  'databaseRow' => [
91  'uid' => 42,
92  'aField' => '1,2,3,4',
93  ],
94  'processedTca' => [
95  'columns' => [
96  'aField' => [
97  'config' => $aFieldConfig,
98  ],
99  ],
100  ],
101  ];
102 
103  ‪$GLOBALS['BE_USER']->workspace = 1;
104 
105  $result = (new ‪TcaGroup())->addData($input);
106  self::assertIsArray($result['databaseRow']['aField'], 'TcaGroup did not load items in a workspace');
107 
108  $loadedUids = array_column($result['databaseRow']['aField'], 'uid');
109  self::assertEquals($loadedUids, [3, 4], 'TcaGroup did not load the correct items in a workspace');
110  }
111 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaGroup
Definition: TcaGroup.php:32
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\setUp
‪setUp()
Definition: TcaGroupTest.php:31
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: TcaGroupTest.php:29
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\respectsDeletedElements
‪respectsDeletedElements()
Definition: TcaGroupTest.php:45
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest
Definition: TcaGroupTest.php:28
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider\TcaGroupTest\respectsDeletedElementsInWorkspace
‪respectsDeletedElementsInWorkspace()
Definition: TcaGroupTest.php:80
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormDataProvider
Definition: TcaGroupTest.php:5