TYPO3 CMS  TYPO3_8-7
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 
22 class DatabaseRowDateTimeFieldsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
28  {
29  $input = [
30  'tableName' => 'aTable',
31  'processedTca' => [
32  'columns' => [
33  'aField' => [
34  'config' => [
35  'dbType' => 'date',
36  ],
37  ],
38  ],
39  ],
40  ];
41  $expected = $input;
42  $expected['databaseRow']['aField'] = 0;
43  $this->assertEquals($expected, (new DatabaseRowDateTimeFields())->addData($input));
44  }
45 
50  {
51  $input = [
52  'tableName' => 'aTable',
53  'processedTca' => [
54  'columns' => [
55  'aField' => [
56  'config' => [
57  'dbType' => 'datetime',
58  ],
59  ],
60  ],
61  ],
62  ];
63  $expected = $input;
64  $expected['databaseRow']['aField'] = 0;
65  $this->assertEquals($expected, (new DatabaseRowDateTimeFields())->addData($input));
66  }
67 
72  {
73  $oldTimezone = date_default_timezone_get();
74  date_default_timezone_set('UTC');
75  $input = [
76  'tableName' => 'aTable',
77  'processedTca' => [
78  'columns' => [
79  'aField' => [
80  'config' => [
81  'dbType' => 'date',
82  ],
83  ],
84  ],
85  ],
86  'databaseRow' => [
87  'aField' => '2015-07-27',
88  ],
89  ];
90  $expected = $input;
91  $expected['databaseRow']['aField'] = '2015-07-27T00:00:00+00:00';
92  $this->assertEquals($expected, (new DatabaseRowDateTimeFields())->addData($input));
93  date_default_timezone_set($oldTimezone);
94  }
95 
100  {
101  $oldTimezone = date_default_timezone_get();
102  date_default_timezone_set('UTC');
103  $input = [
104  'tableName' => 'aTable',
105  'processedTca' => [
106  'columns' => [
107  'aField' => [
108  'config' => [
109  'dbType' => 'datetime',
110  ],
111  ],
112  ],
113  ],
114  'databaseRow' => [
115  'aField' => '2015-07-27 15:25:32',
116  ],
117  ];
118  $expected = $input;
119  $expected['databaseRow']['aField'] = '2015-07-27T15:25:32+00:00';
120  $this->assertEquals($expected, (new DatabaseRowDateTimeFields())->addData($input));
121  date_default_timezone_set($oldTimezone);
122  }
123 }