summaryrefslogtreecommitdiff
path: root/tests/units/Model/TimezoneTest.php
blob: 8e7103d81a258c28272acc1a22e3f7a9d11dedf7 (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
<?php

require_once __DIR__.'/../Base.php';

use Kanboard\Model\TimezoneModel;

class TimezoneTest extends Base
{
    public function testGetTimezones()
    {
        $timezoneModel = new TimezoneModel($this->container);
        $this->assertNotEmpty($timezoneModel->getTimezones());
        $this->assertArrayHasKey('Europe/Paris', $timezoneModel->getTimezones());
        $this->assertContains('Europe/Paris', $timezoneModel->getTimezones());
        $this->assertArrayNotHasKey('', $timezoneModel->getTimezones());

        $this->assertArrayHasKey('', $timezoneModel->getTimezones(true));
        $this->assertContains('Application default', $timezoneModel->getTimezones(true));
    }

    public function testGetCurrentTimezone()
    {
        $timezoneModel = new TimezoneModel($this->container);
        $this->assertEquals('UTC', $timezoneModel->getCurrentTimezone());

        $this->container['sessionStorage']->user = array('timezone' => 'Europe/Paris');
        $this->assertEquals('Europe/Paris', $timezoneModel->getCurrentTimezone());

        $this->container['sessionStorage']->user = array('timezone' => 'Something');
        $this->assertEquals('Something', $timezoneModel->getCurrentTimezone());
    }
}