‪TYPO3CMS  10.4
DatabaseRowDefaultValuesTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪DatabaseRowDefaultValuesTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->subject = new ‪DatabaseRowDefaultValues();
35  }
36 
40  public function ‪addDataKeepsExistingValue()
41  {
42  $input = [
43  'databaseRow' => [
44  'aDefinedField' => 'aValue',
45  ],
46  'processedTca' => [
47  'columns' => [
48  'aDefinedField' => [],
49  ],
50  ],
51  ];
52  $expected = $input;
53  self::assertSame($expected, $this->subject->addData($input));
54  }
55 
60  {
61  $input = [
62  'databaseRow' => [
63  'aField' => null,
64  ],
65  'processedTca' => [
66  'columns' => [
67  'aField' => [
68  'config' => [
69  'eval' => 'null',
70  ],
71  ],
72  ],
73  ],
74  ];
75  $expected = $input;
76  self::assertSame($expected, $this->subject->addData($input));
77  }
78 
83  {
84  $input = [
85  'databaseRow' => [],
86  'processedTca' => [
87  'columns' => [
88  'aField' => [
89  'config' => [
90  'eval' => 'null',
91  'default' => null,
92  ],
93  ],
94  ],
95  ],
96  ];
97  $expected = $input;
98  $expected['databaseRow']['aField'] = null;
99  self::assertSame($expected, $this->subject->addData($input));
100  }
101 
106  {
107  $input = [
108  'databaseRow' => [],
109  'processedTca' => [
110  'columns' => [
111  'aField' => [
112  'config' => [
113  'eval' => 'null',
114  'default' => 'foo',
115  ],
116  ],
117  ],
118  ],
119  ];
120  $expected = $input;
121  $expected['databaseRow']['aField'] = 'foo';
122  self::assertSame($expected, $this->subject->addData($input));
123  }
124 
128  public function ‪addDataSetsDefaultValueIsSet()
129  {
130  $input = [
131  'databaseRow' => [],
132  'processedTca' => [
133  'columns' => [
134  'aField' => [
135  'config' => [
136  'default' => 'foo',
137  ],
138  ],
139  ],
140  ],
141  ];
142  $expected = $input;
143  $expected['databaseRow']['aField'] = 'foo';
144  self::assertSame($expected, $this->subject->addData($input));
145  }
146 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest
Definition: DatabaseRowDefaultValuesTest.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues
Definition: DatabaseRowDefaultValues.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsDefaultValueIfEvalNullIsSet
‪addDataSetsDefaultValueIfEvalNullIsSet()
Definition: DatabaseRowDefaultValuesTest.php:104
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataKeepsExistingNullValueWithEvalNull
‪addDataKeepsExistingNullValueWithEvalNull()
Definition: DatabaseRowDefaultValuesTest.php:58
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataKeepsExistingValue
‪addDataKeepsExistingValue()
Definition: DatabaseRowDefaultValuesTest.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\setUp
‪setUp()
Definition: DatabaseRowDefaultValuesTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\$subject
‪DatabaseRowDefaultValues $subject
Definition: DatabaseRowDefaultValuesTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsDefaultValueIsSet
‪addDataSetsDefaultValueIsSet()
Definition: DatabaseRowDefaultValuesTest.php:127
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsNullValueWithDefaultNullForNewRecord
‪addDataSetsNullValueWithDefaultNullForNewRecord()
Definition: DatabaseRowDefaultValuesTest.php:81
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18