blob: d5a62a9732fe94dcbf42c26bf7b1e323a29d02ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Tests\unit\CalDAV;
use DateTimeZone;
use OCA\DAV\CalDAV\TimeZoneFactory;
use Test\TestCase;
class TimeZoneFactoryTest extends TestCase {
private TimeZoneFactory $factory;
protected function setUp(): void {
parent::setUp();
$this->factory = new TimeZoneFactory();
}
public function testIsMS(): void {
// test Microsoft time zone
$this->assertTrue(TimeZoneFactory::isMS('Eastern Standard Time'));
// test IANA time zone
$this->assertFalse(TimeZoneFactory::isMS('America/Toronto'));
// test Fake time zone
$this->assertFalse(TimeZoneFactory::isMS('Fake Eastern Time'));
}
public function testToIana(): void {
// test Microsoft time zone
$this->assertEquals('America/Toronto', TimeZoneFactory::toIANA('Eastern Standard Time'));
// test IANA time zone
$this->assertEquals(null, TimeZoneFactory::toIANA('America/Toronto'));
// test Fake time zone
$this->assertEquals(null, TimeZoneFactory::toIANA('Fake Eastern Time'));
}
public function testFromName(): void {
// test Microsoft time zone
$this->assertEquals(new DateTimeZone('America/Toronto'), $this->factory->fromName('Eastern Standard Time'));
// test IANA time zone
$this->assertEquals(new DateTimeZone('America/Toronto'), $this->factory->fromName('America/Toronto'));
// test Fake time zone
$this->assertEquals(null, $this->factory->fromName('Fake Eastern Time'));
}
}
|