mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-25 08:14:29 +02:00
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Auth\User;
|
|
use App\Models\List\Playlist;
|
|
use App\Models\User\Like;
|
|
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
|
|
uses(WithFaker::class);
|
|
|
|
test('nameable', function (): void {
|
|
$like = Like::factory()
|
|
->forPlaylist()
|
|
->createOne();
|
|
|
|
$this->assertIsString($like->getName());
|
|
});
|
|
|
|
test('has subtitle', function (): void {
|
|
$like = Like::factory()
|
|
->forPlaylist()
|
|
->createOne();
|
|
|
|
$this->assertIsString($like->getSubtitle());
|
|
});
|
|
|
|
test('playlist', function (): void {
|
|
$like = Like::factory()
|
|
->forPlaylist()
|
|
->createOne();
|
|
|
|
$this->assertInstanceOf(MorphTo::class, $like->likeable());
|
|
$this->assertInstanceOf(Playlist::class, $like->likeable()->first());
|
|
});
|
|
|
|
test('entry', function (): void {
|
|
$like = Like::factory()
|
|
->forEntry()
|
|
->createOne();
|
|
|
|
$this->assertInstanceOf(MorphTo::class, $like->likeable());
|
|
$this->assertInstanceOf(AnimeThemeEntry::class, $like->likeable()->first());
|
|
});
|
|
|
|
test('user', function (): void {
|
|
$like = Like::factory()
|
|
->forPlaylist()
|
|
->createOne();
|
|
|
|
$this->assertInstanceOf(BelongsTo::class, $like->user());
|
|
$this->assertInstanceOf(User::class, $like->user()->first());
|
|
});
|