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