‪TYPO3CMS  10.4
TcaInlineTest.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 
18 use Prophecy\Prophecy\ObjectProphecy;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪TcaInlineTest extends UnitTestCase
27 {
31  protected ‪$beUserProphecy;
32 
33  protected function ‪setUp(): void
34  {
35  parent::setUp();
36  $this->beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
37  ‪$GLOBALS['BE_USER'] = $this->beUserProphecy->reveal();
38  }
39 
44  {
45  $input = [
46  'processedTca' => [
47  'columns' => [
48  'aField' => [
49  'config' => [
50  'type' => 'inline',
51  'foreign_table' => 'aForeignTableName',
52  ],
53  ],
54  ],
55  ],
56  'inlineFirstPid' => 0,
57  ];
58 
59  $this->beUserProphecy
60  ->check(
61  'tables_modify',
62  $input['processedTca']['columns']['aField']['config']['foreign_table']
63  )
64  ->shouldBeCalled()
65  ->willReturn(false);
66 
67  $expected = $input;
68  $expected['processedTca']['columns']['aField']['children'] = [];
69  self::assertEquals($expected, (new ‪TcaInline())->addData($input));
70  }
71 
76  {
77  $input = [
78  'processedTca' => [
79  'columns' => [
80  'aField' => [
81  'config' => [
82  'type' => 'input',
83  'foreign_table' => 'aForeignTableName',
84  ],
85  ],
86  ],
87  ],
88  'inlineFirstPid' => 0,
89  ];
90 
91  $this->beUserProphecy
92  ->check(
93  'tables_modify',
94  $input['processedTca']['columns']['aField']['config']['foreign_table']
95  )
96  ->shouldNotBeCalled();
97 
98  $expected = $input;
99  $expected['processedTca']['columns']['aField']['config']['type'] = 'input';
100  self::assertEquals($expected, (new TcaInline())->addData($input));
101  }
102 
107  {
108  $input = [
109  'processedTca' => [
110  'columns' => [
111  'aField' => [
112  'config' => [
113  'type' => 'inline',
114  'foreign_table' => 'aForeignTableName',
115  ],
116  ],
117  ],
118  ],
119  'inlineFirstPid' => 0,
120  'inlineResolveExistingChildren' => false,
121  ];
122 
123  $this->beUserProphecy
124  ->check(
125  'tables_modify',
126  $input['processedTca']['columns']['aField']['config']['foreign_table']
127  )
128  ->shouldBeCalled()
129  ->willReturn(true);
130 
131  $expected = $input;
132  $expected['processedTca']['columns']['aField']['children'] = [];
133  self::assertEquals($expected, (new TcaInline())->addData($input));
134  }
135 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaInline
Definition: TcaInline.php:38
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest\addDataWithoutModifyRightsButWithInlineTypeWillNotParseChildren
‪addDataWithoutModifyRightsButWithInlineTypeWillNotParseChildren()
Definition: TcaInlineTest.php:42
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest\setUp
‪setUp()
Definition: TcaInlineTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest\addDataWithInlineTypeAndModifyRightsWillAddChildren
‪addDataWithInlineTypeAndModifyRightsWillAddChildren()
Definition: TcaInlineTest.php:105
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest\addDataWithUserRightsButWithoutInlineTypeWillNotParseChildren
‪addDataWithUserRightsButWithoutInlineTypeWillNotParseChildren()
Definition: TcaInlineTest.php:74
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest\$beUserProphecy
‪BackendUserAuthentication ObjectProphecy $beUserProphecy
Definition: TcaInlineTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaInlineTest
Definition: TcaInlineTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18