koel/tests/Integration/Models/UserTest.php
2020-09-06 20:21:39 +02:00

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 = factory(User::class)->create();
$user->setPreference('foo', 'bar');
self::assertSame('bar', $user->preferences['foo']);
}
public function testGetUserPreferences(): void
{
/** @var User $user */
$user = factory(User::class)->create([
'preferences' => ['foo' => 'bar'],
]);
self::assertEquals('bar', $user->getPreference('foo'));
}
public function testDeleteUserPreferences(): void
{
/** @var User $user */
$user = factory(User::class)->create([
'preferences' => ['foo' => 'bar'],
]);
$user->deletePreference('foo');
self::assertArrayNotHasKey('foo', $user->preferences);
}
public function testSensitivePreferencesAreHidden(): void
{
/** @var User $user */
$user = factory(User::class)->create([
'preferences' => ['lastfm_session_key' => 'foo'],
]);
self::assertEquals('hidden', $user->preferences['lastfm_session_key']);
}
}