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