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