‪TYPO3CMS  10.4
DatabaseRowDateTimeFieldsTest.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 ‪DatabaseRowDateTimeFieldsTest extends UnitTestCase
25 {
30  {
31  $input = [
32  'tableName' => 'aTable',
33  'processedTca' => [
34  'columns' => [
35  'aField' => [
36  'config' => [
37  'dbType' => 'date',
38  ],
39  ],
40  ],
41  ],
42  ];
43  $expected = $input;
44  $expected['databaseRow']['aField'] = 0;
45  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
46  }
47 
52  {
53  $input = [
54  'tableName' => 'aTable',
55  'processedTca' => [
56  'columns' => [
57  'aField' => [
58  'config' => [
59  'dbType' => 'datetime',
60  ],
61  ],
62  ],
63  ],
64  ];
65  $expected = $input;
66  $expected['databaseRow']['aField'] = 0;
67  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
68  }
69 
74  {
75  $input = [
76  'tableName' => 'aTable',
77  'processedTca' => [
78  'columns' => [
79  'aField' => [
80  'config' => [
81  'dbType' => 'time',
82  ],
83  ],
84  ],
85  ],
86  ];
87  $expected = $input;
88  $expected['databaseRow']['aField'] = 0;
89  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
90  }
91 
96  {
97  $oldTimezone = date_default_timezone_get();
98  date_default_timezone_set('UTC');
99  $input = [
100  'tableName' => 'aTable',
101  'processedTca' => [
102  'columns' => [
103  'aField' => [
104  'config' => [
105  'dbType' => 'date',
106  ],
107  ],
108  ],
109  ],
110  'databaseRow' => [
111  'aField' => '2015-07-27',
112  ],
113  ];
114  $expected = $input;
115  $expected['databaseRow']['aField'] = '2015-07-27T00:00:00+00:00';
116  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
117  date_default_timezone_set($oldTimezone);
118  }
119 
124  {
125  $oldTimezone = date_default_timezone_get();
126  date_default_timezone_set('UTC');
127  $input = [
128  'tableName' => 'aTable',
129  'processedTca' => [
130  'columns' => [
131  'aField' => [
132  'config' => [
133  'dbType' => 'datetime',
134  ],
135  ],
136  ],
137  ],
138  'databaseRow' => [
139  'aField' => '2015-07-27 15:25:32',
140  ],
141  ];
142  $expected = $input;
143  $expected['databaseRow']['aField'] = '2015-07-27T15:25:32+00:00';
144  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
145  date_default_timezone_set($oldTimezone);
146  }
147 
152  {
153  $oldTimezone = date_default_timezone_get();
154  date_default_timezone_set('UTC');
155  $input = [
156  'tableName' => 'aTable',
157  'processedTca' => [
158  'columns' => [
159  'aField' => [
160  'config' => [
161  'dbType' => 'time',
162  ],
163  ],
164  ],
165  ],
166  'databaseRow' => [
167  'aField' => '15:25:32',
168  ],
169  ];
170  $expected = $input;
171  $expected['databaseRow']['aField'] = date('Y-m-d') . 'T15:25:32+00:00';
172  self::assertEquals($expected, (new ‪DatabaseRowDateTimeFields())->addData($input));
173  date_default_timezone_set($oldTimezone);
174  }
175 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataSetsTimestampZeroForDefaultDateField
‪addDataSetsTimestampZeroForDefaultDateField()
Definition: DatabaseRowDateTimeFieldsTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataSetsTimestampZeroForDefaultTimeField
‪addDataSetsTimestampZeroForDefaultTimeField()
Definition: DatabaseRowDateTimeFieldsTest.php:73
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataConvertsTimeStringToTimestamp
‪addDataConvertsTimeStringToTimestamp()
Definition: DatabaseRowDateTimeFieldsTest.php:151
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDateTimeFields
Definition: DatabaseRowDateTimeFields.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataSetsTimestampZeroForDefaultDateTimeField
‪addDataSetsTimestampZeroForDefaultDateTimeField()
Definition: DatabaseRowDateTimeFieldsTest.php:51
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest
Definition: DatabaseRowDateTimeFieldsTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataConvertsDateTimeStringToTimestamp
‪addDataConvertsDateTimeStringToTimestamp()
Definition: DatabaseRowDateTimeFieldsTest.php:123
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRowDateTimeFieldsTest\addDataConvertsDateStringToTimestamp
‪addDataConvertsDateStringToTimestamp()
Definition: DatabaseRowDateTimeFieldsTest.php:95
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18