2021-06-04 16:19:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\Casts;
|
|
|
|
|
|
|
|
use App\Values\UserPreferences;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-01-11 12:41:33 +00:00
|
|
|
use function Tests\create_user;
|
|
|
|
|
2021-06-04 16:19:34 +00:00
|
|
|
class UserPreferencesCastTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testCast(): void
|
|
|
|
{
|
2024-01-11 12:41:33 +00:00
|
|
|
$user = create_user([
|
2021-06-04 16:19:34 +00:00
|
|
|
'preferences' => [
|
|
|
|
'lastfm_session_key' => 'foo',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
self::assertInstanceOf(UserPreferences::class, $user->preferences);
|
|
|
|
self::assertSame('foo', $user->preferences->lastFmSessionKey);
|
|
|
|
|
|
|
|
$user->preferences->lastFmSessionKey = 'bar';
|
|
|
|
$user->save();
|
|
|
|
self::assertSame('bar', $user->refresh()->preferences->lastFmSessionKey);
|
|
|
|
|
|
|
|
$user->preferences->lastFmSessionKey = null;
|
|
|
|
$user->save();
|
|
|
|
self::assertNull($user->refresh()->preferences->lastFmSessionKey);
|
|
|
|
}
|
|
|
|
}
|