mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-10 09:01:04 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
namespace Tests\Icinga\User;
|
|
|
|
use Icinga\User\Preferences;
|
|
use Icinga\Test\BaseTestCase;
|
|
|
|
class PreferencesTest extends BaseTestCase
|
|
{
|
|
public function testWhetherPreferencesCanBeSet()
|
|
{
|
|
$prefs = new Preferences();
|
|
|
|
$prefs->key = 'value';
|
|
$this->assertTrue(isset($prefs->key));
|
|
$this->assertEquals('value', $prefs->key);
|
|
}
|
|
|
|
public function testWhetherPreferencesCanBeAccessed()
|
|
{
|
|
$prefs = new Preferences(array('key' => 'value'));
|
|
|
|
$this->assertTrue($prefs->has('key'));
|
|
$this->assertEquals('value', $prefs->get('key'));
|
|
}
|
|
|
|
public function testWhetherPreferencesCanBeRemoved()
|
|
{
|
|
$prefs = new Preferences(array('key' => 'value'));
|
|
|
|
unset($prefs->key);
|
|
$this->assertFalse(isset($prefs->key));
|
|
|
|
$prefs->key = 'value';
|
|
$prefs->remove('key');
|
|
$this->assertFalse($prefs->has('key'));
|
|
}
|
|
|
|
public function testWhetherPreferencesAreCountable()
|
|
{
|
|
$prefs = new Preferences(array('key1' => '1', 'key2' => '2'));
|
|
|
|
$this->assertEquals(2, count($prefs));
|
|
}
|
|
|
|
public function testWhetherGetValueReturnsExpectedValue()
|
|
{
|
|
$prefs = new Preferences(array(
|
|
'test' => array (
|
|
'key1' => '1',
|
|
'key2' => '2',
|
|
)
|
|
));
|
|
|
|
$result = $prefs->getValue('test', 'key2');
|
|
|
|
$this->assertEquals('2', $result, 'Preferences::getValue() do not return an expected value');
|
|
}
|
|
}
|