mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Integration\Models;
|
|
|
|
use App\Models\User;
|
|
use Tests\TestCase;
|
|
|
|
class UserTest extends TestCase
|
|
{
|
|
public function testSetUserPreferences(): void
|
|
{
|
|
/** @var User $user */
|
|
$user = User::factory()->create();
|
|
$user->setPreference('foo', 'bar');
|
|
|
|
self::assertSame('bar', $user->preferences['foo']);
|
|
}
|
|
|
|
public function testGetUserPreferences(): void
|
|
{
|
|
/** @var User $user */
|
|
$user = User::factory()->create([
|
|
'preferences' => ['foo' => 'bar'],
|
|
]);
|
|
|
|
self::assertEquals('bar', $user->getPreference('foo'));
|
|
}
|
|
|
|
public function testDeleteUserPreferences(): void
|
|
{
|
|
/** @var User $user */
|
|
$user = User::factory()->create([
|
|
'preferences' => ['foo' => 'bar'],
|
|
]);
|
|
$user->deletePreference('foo');
|
|
|
|
self::assertArrayNotHasKey('foo', $user->preferences);
|
|
}
|
|
|
|
public function testSensitivePreferencesAreHidden(): void
|
|
{
|
|
/** @var User $user */
|
|
$user = User::factory()->create([
|
|
'preferences' => ['lastfm_session_key' => 'foo'],
|
|
]);
|
|
|
|
self::assertEquals('hidden', $user->preferences['lastfm_session_key']);
|
|
}
|
|
}
|