[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / PageTsConfigMergedTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
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 TYPO3\CMS\Backend\Form\FormDataProvider\PageTsConfigMerged;
18
19 /**
20 * Test case
21 */
22 class PageTsConfigMergedTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
23 {
24 /**
25 * @var PageTsConfigMerged
26 */
27 protected $subject;
28
29 protected function setUp()
30 {
31 $this->subject = new PageTsConfigMerged();
32 }
33
34 /**
35 * @test
36 */
37 public function addDataSetsMergedTsConfigToTsConfig()
38 {
39 $input = [
40 'tableName' => 'aTable',
41 '' => 'aType',
42 'pageTsConfig' => [
43 'aSetting' => 'aValue',
44 ],
45 ];
46 $expected = $input;
47 $expected['pageTsConfig'] = $input['pageTsConfig'];
48 $this->assertSame($expected, $this->subject->addData($input));
49 }
50
51 /**
52 * @test
53 */
54 public function addDataKeepsTableSpecificConfigurationWithoutType()
55 {
56 $input = [
57 'tableName' => 'aTable',
58 'recordTypeValue' => 'aType',
59 'pageTsConfig' => [
60 'TCEFORM.' => [
61 'aTable.' => [
62 'aField.' => [
63 'disabled' => 1,
64 ],
65 ],
66 ],
67 ],
68 ];
69 $expected = $input;
70 $expected['pageTsConfig'] = $input['pageTsConfig'];
71 $this->assertSame($expected, $this->subject->addData($input));
72 }
73
74 /**
75 * @test
76 */
77 public function addDataMergesTypeSpecificConfiguration()
78 {
79 $input = [
80 'tableName' => 'aTable',
81 'recordTypeValue' => 'aType',
82 'pageTsConfig' => [
83 'TCEFORM.' => [
84 'aTable.' => [
85 'aField.' => [
86 'types.' => [
87 'aType.' => [
88 'disabled' => 1,
89 ],
90 ],
91 ],
92 ],
93 ],
94 ],
95 ];
96 $expected = $input;
97 $expected['pageTsConfig'] = [
98 'TCEFORM.' => [
99 'aTable.' => [
100 'aField.' => [
101 'disabled' => 1,
102 ],
103 ],
104 ],
105 ];
106 $this->assertSame($expected, $this->subject->addData($input));
107 }
108
109 /**
110 * @test
111 */
112 public function addDataTypeSpecificConfigurationOverwritesMainConfiguration()
113 {
114 $input = [
115 'tableName' => 'aTable',
116 'recordTypeValue' => 'aType',
117 'pageTsConfig' => [
118 'TCEFORM.' => [
119 'aTable.' => [
120 'aField.' => [
121 'disabled' => 0,
122 'types.' => [
123 'aType.' => [
124 'disabled' => 1,
125 ],
126 ],
127 ],
128 ],
129 ],
130 ],
131 ];
132 $expected = $input;
133 $expected['pageTsConfig'] = [
134 'TCEFORM.' => [
135 'aTable.' => [
136 'aField.' => [
137 'disabled' => 1,
138 ],
139 ],
140 ],
141 ];
142 $this->assertSame($expected, $this->subject->addData($input));
143 }
144 }