mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add unit test
This commit is contained in:
parent
c855ef874b
commit
e845e8876d
1 changed files with 12 additions and 0 deletions
|
@ -421,6 +421,18 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testNiceTimezoneConversion() {
|
||||
date_default_timezone_set('Europe/Copenhagen'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
|
||||
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
|
||||
// Convert to UTC.
|
||||
$actual = CakeTime::nice($clientDateTime, 'UTC', '%Y-%m-%d %H:%M:%S');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i:s');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* testNiceShort method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue