TYPO3 CMS  TYPO3_7-6
InputTextElementTest.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 
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', 1457103519 + 3600
63  ],
64  'date in 1969 in German timezone' => [
65  -7200, 'Europe/Berlin', -3600
66  ],
67  // Los Angeles is 8 hours behind UTC
68  'date in 2016 in Los Angeles timezone' => [
69  1457103519, 'America/Los_Angeles', 1457103519 - 28800
70  ],
71  'date in UTC' => [
72  1457103519, 'UTC', 1457103519
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 }