‪TYPO3CMS  9.5
DatabaseRowDefaultValuesTest.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 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪DatabaseRowDefaultValuesTest extends UnitTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp()
31  {
32  $this->subject = new ‪DatabaseRowDefaultValues();
33  }
34 
38  public function ‪addDataKeepsExistingValue()
39  {
40  $input = [
41  'databaseRow' => [
42  'aDefinedField' => 'aValue',
43  ],
44  'processedTca' => [
45  'columns' => [
46  'aDefinedField' => [],
47  ],
48  ],
49  ];
50  $expected = $input;
51  $this->assertSame($expected, $this->subject->addData($input));
52  }
53 
58  {
59  $input = [
60  'databaseRow' => [
61  'aField' => null,
62  ],
63  'processedTca' => [
64  'columns' => [
65  'aField' => [
66  'config' => [
67  'eval' => 'null',
68  ],
69  ],
70  ],
71  ],
72  ];
73  $expected = $input;
74  $this->assertSame($expected, $this->subject->addData($input));
75  }
76 
81  {
82  $input = [
83  'databaseRow' => [],
84  'processedTca' => [
85  'columns' => [
86  'aField' => [
87  'config' => [
88  'eval' => 'null',
89  'default' => null,
90  ],
91  ],
92  ],
93  ],
94  ];
95  $expected = $input;
96  $expected['databaseRow']['aField'] = null;
97  $this->assertSame($expected, $this->subject->addData($input));
98  }
99 
104  {
105  $input = [
106  'databaseRow' => [],
107  'processedTca' => [
108  'columns' => [
109  'aField' => [
110  'config' => [
111  'eval' => 'null',
112  'default' => 'foo',
113  ],
114  ],
115  ],
116  ],
117  ];
118  $expected = $input;
119  $expected['databaseRow']['aField'] = 'foo';
120  $this->assertSame($expected, $this->subject->addData($input));
121  }
122 
126  public function ‪addDataSetsDefaultValueIsSet()
127  {
128  $input = [
129  'databaseRow' => [],
130  'processedTca' => [
131  'columns' => [
132  'aField' => [
133  'config' => [
134  'default' => 'foo',
135  ],
136  ],
137  ],
138  ],
139  ];
140  $expected = $input;
141  $expected['databaseRow']['aField'] = 'foo';
142  $this->assertSame($expected, $this->subject->addData($input));
143  }
144 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest
Definition: DatabaseRowDefaultValuesTest.php:24
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues
Definition: DatabaseRowDefaultValues.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsDefaultValueIfEvalNullIsSet
‪addDataSetsDefaultValueIfEvalNullIsSet()
Definition: DatabaseRowDefaultValuesTest.php:102
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataKeepsExistingNullValueWithEvalNull
‪addDataKeepsExistingNullValueWithEvalNull()
Definition: DatabaseRowDefaultValuesTest.php:56
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataKeepsExistingValue
‪addDataKeepsExistingValue()
Definition: DatabaseRowDefaultValuesTest.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\setUp
‪setUp()
Definition: DatabaseRowDefaultValuesTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\$subject
‪DatabaseRowDefaultValues $subject
Definition: DatabaseRowDefaultValuesTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsDefaultValueIsSet
‪addDataSetsDefaultValueIsSet()
Definition: DatabaseRowDefaultValuesTest.php:125
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDefaultValuesTest\addDataSetsNullValueWithDefaultNullForNewRecord
‪addDataSetsNullValueWithDefaultNullForNewRecord()
Definition: DatabaseRowDefaultValuesTest.php:79
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3