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