mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-11-13 09:38:48 +01:00
56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Auth\User;
|
|
use App\Models\List\Playlist;
|
|
use App\Models\List\Playlist\PlaylistTrack;
|
|
use App\Models\Wiki\Video;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
test('nameable', function (): void {
|
|
$track = PlaylistTrack::factory()
|
|
->for(Playlist::factory())
|
|
->createOne();
|
|
|
|
expect($track->getName())->toBeString();
|
|
});
|
|
|
|
test('has subtitle', function (): void {
|
|
$track = PlaylistTrack::factory()
|
|
->for(Playlist::factory()->for(User::factory()))
|
|
->createOne();
|
|
|
|
expect($track->getSubtitle())->toBeString();
|
|
});
|
|
|
|
test('hashids', function (): void {
|
|
$playlist = Playlist::factory()->createOne();
|
|
|
|
$track = PlaylistTrack::factory()
|
|
->for($playlist)
|
|
->createOne();
|
|
|
|
expect(array_diff([$playlist->playlist_id, $track->track_id], $track->hashids()))->toBeEmpty();
|
|
expect(array_diff($track->hashids(), [$playlist->playlist_id, $track->track_id]))->toBeEmpty();
|
|
});
|
|
|
|
test('playlist', function (): void {
|
|
$track = PlaylistTrack::factory()
|
|
->for(Playlist::factory())
|
|
->createOne();
|
|
|
|
expect($track->playlist())->toBeInstanceOf(BelongsTo::class);
|
|
expect($track->playlist()->first())->toBeInstanceOf(Playlist::class);
|
|
});
|
|
|
|
test('video', function (): void {
|
|
$track = PlaylistTrack::factory()
|
|
->for(Playlist::factory())
|
|
->for(Video::factory())
|
|
->createOne();
|
|
|
|
expect($track->video())->toBeInstanceOf(BelongsTo::class);
|
|
expect($track->video()->first())->toBeInstanceOf(Video::class);
|
|
});
|