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