2013-06-07 12:40:21 +02:00
|
|
|
<?php
|
2014-04-10 10:32:50 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
2013-06-07 12:40:21 +02:00
|
|
|
|
2013-07-26 15:58:16 +02:00
|
|
|
namespace Tests\Icinga;
|
2013-08-06 18:02:40 +02:00
|
|
|
|
2013-08-07 17:19:16 +02:00
|
|
|
use \DateTimeZone;
|
2014-04-10 10:32:50 +02:00
|
|
|
use Icinga\User;
|
|
|
|
use Icinga\User\Preferences;
|
|
|
|
use Icinga\Test\BaseTestCase;
|
2013-08-06 18:02:40 +02:00
|
|
|
|
2014-04-10 10:32:50 +02:00
|
|
|
class UserTest extends BaseTestCase
|
2013-06-07 12:40:21 +02:00
|
|
|
{
|
2013-08-06 18:02:40 +02:00
|
|
|
public function testGetDefaultTimezoneIfTimezoneNotSet()
|
|
|
|
{
|
2014-04-10 10:32:50 +02:00
|
|
|
$user = new User('unittest');
|
|
|
|
$prefs = new Preferences(array());
|
2013-08-06 18:02:40 +02:00
|
|
|
$user->setPreferences($prefs);
|
2014-04-10 10:32:50 +02:00
|
|
|
$this->assertEquals($user->getTimeZone(), new DateTimeZone(date_default_timezone_get()),
|
2013-08-06 18:02:40 +02:00
|
|
|
'User\'s timezone does not match the default timezone'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTimezoneIfTimezoneSet()
|
|
|
|
{
|
|
|
|
$explicitTz = 'Europe/Berlin';
|
2014-04-10 10:32:50 +02:00
|
|
|
$user = new User('unittest');
|
|
|
|
$prefs = new Preferences(array(
|
2013-08-06 18:02:40 +02:00
|
|
|
'timezone' => $explicitTz
|
|
|
|
));
|
|
|
|
$user->setPreferences($prefs);
|
2013-08-20 11:27:25 +02:00
|
|
|
|
|
|
|
$this->assertEquals($user->getTimeZone(), new DateTimeZone($explicitTz),
|
2013-08-06 18:02:40 +02:00
|
|
|
'User\'s timezone does not match the timezone set by himself'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-06-07 12:40:21 +02:00
|
|
|
}
|