TYPO3 CMS  TYPO3_8-7
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 
20 
24 class TcaInlineTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
25 {
29  protected $subject;
30 
34  protected $beUserProphecy;
35 
36  protected function setUp()
37  {
38  $this->beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
39  $GLOBALS['BE_USER'] = $this->beUserProphecy->reveal();
40 
41  $this->subject = new TcaInline();
42  }
43 
47  protected $defaultConfig = [
48  'processedTca' => [
49  'columns' => [
50  'aField' => [
51  'config' => [
52  'type' => 'inline',
53  'foreign_table' => 'aForeignTableName'
54  ],
55  ],
56  ],
57  ],
58  'inlineFirstPid' => 0,
59  ];
60 
65  {
66  $input = [
67  'processedTca' => [
68  'columns' => [
69  'aField' => [
70  'config' => [
71  'type' => 'inline',
72  'foreign_table' => 'aForeignTableName',
73  ],
74  ],
75  ],
76  ],
77  ];
78 
79  $this->beUserProphecy
80  ->check(
81  'tables_modify',
82  $input['processedTca']['columns']['aField']['config']['foreign_table']
83  )
84  ->shouldBeCalled()
85  ->willReturn(false);
86 
87  $expected = $this->defaultConfig;
88  $expected['processedTca']['columns']['aField']['children'] = [];
89  $this->assertEquals($expected, $this->subject->addData($input));
90  }
91 
96  {
97  $input = [
98  'processedTca' => [
99  'columns' => [
100  'aField' => [
101  'config' => [
102  'type' => 'input',
103  'foreign_table' => 'aForeignTableName',
104  ],
105  ],
106  ],
107  ],
108  ];
109 
110  $this->beUserProphecy
111  ->check(
112  'tables_modify',
113  $input['processedTca']['columns']['aField']['config']['foreign_table']
114  )
115  ->shouldNotBeCalled();
116 
117  $expected = $this->defaultConfig;
118  $expected['processedTca']['columns']['aField']['config']['type'] = 'input';
119  $this->assertEquals($expected, $this->subject->addData($input));
120  }
121 
126  {
127  $input = [
128  'processedTca' => [
129  'columns' => [
130  'aField' => [
131  'config' => [
132  'type' => 'inline',
133  'foreign_table' => 'aForeignTableName',
134  ],
135  ],
136  ],
137  ],
138  ];
139 
140  $this->beUserProphecy
141  ->check(
142  'tables_modify',
143  $input['processedTca']['columns']['aField']['config']['foreign_table']
144  )
145  ->shouldBeCalled()
146  ->willReturn(true);
147 
148  $expected = $this->defaultConfig;
149  $expected['processedTca']['columns']['aField']['children'] = [];
150  $this->assertEquals($expected, $this->subject->addData($input));
151  }
152 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']