TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
InputTextElementTest.php
Go to the documentation of this file.
1 <?php
2 namespace typo3\sysext\backend\Tests\Unit\Form\Element;
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 
20 
25 {
29  protected $timezoneBackup = '';
30 
37  protected function setUp()
38  {
39  $this->timezoneBackup = date_default_timezone_get();
40  }
41 
45  protected function tearDown()
46  {
47  date_default_timezone_set($this->timezoneBackup);
48  parent::tearDown();
49  }
50 
57  {
58  // Three elements: input (UTC), timezone of output, expected output
59  return [
60  // German standard time (without DST) is one hour ahead of UTC
61  'date in 2016 in German timezone' => [
62  1457103519, 'Europe/Berlin', '2016-03-04T15:58:39+00:00'
63  ],
64  'date in 1969 in German timezone' => [
65  -7200, 'Europe/Berlin', '1969-12-31T23:00:00+00:00'
66  ],
67  // Los Angeles is 8 hours behind UTC
68  'date in 2016 in Los Angeles timezone' => [
69  1457103519, 'America/Los_Angeles', '2016-03-04T06:58:39+00:00'
70  ],
71  'date in UTC' => [
72  1457103519, 'UTC', '2016-03-04T14:58:39+00:00'
73  ]
74  ];
75  }
76 
84  public function renderAppliesCorrectTimestampConversion($input, $serverTimezone, $expectedOutput)
85  {
86  date_default_timezone_set($serverTimezone);
87  $data = [
88  'parameterArray' => [
89  'tableName' => 'table_foo',
90  'fieldName' => 'field_bar',
91  'fieldConf' => [
92  'config' => [
93  'type' => 'input',
94  'dbType' => 'datetime',
95  'eval' => 'datetime',
96  'default' => '0000-00-00 00:00:00'
97  ]
98  ],
99  'itemFormElValue' => $input
100  ]
101  ];
103  $nodeFactoryProphecy = $this->prophesize(NodeFactory::class)->reveal();
104  $subject = new InputTextElement($nodeFactoryProphecy, $data);
105  $result = $subject->render();
106  $this->assertContains('<input type="hidden" name="" value="' . $expectedOutput . '" />', $result['html']);
107  }
108 }