mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-11-13 09:38:48 +01:00
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Wiki\Anime;
|
|
use App\Models\Wiki\Series;
|
|
use App\Pivots\Wiki\AnimeSeries;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
|
|
pest()->use(WithFaker::class);
|
|
|
|
test('searchable as', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
expect($series->searchableAs())->toBeString();
|
|
});
|
|
|
|
test('to searchable array', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
expect($series->toSearchableArray())->toBeArray();
|
|
});
|
|
|
|
test('nameable', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
expect($series->getName())->toBeString();
|
|
});
|
|
|
|
test('has subtitle', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
expect($series->getSubtitle())->toBeString();
|
|
});
|
|
|
|
test('anime', function (): void {
|
|
$animeCount = fake()->randomDigitNotNull();
|
|
|
|
$series = Series::factory()
|
|
->has(Anime::factory()->count($animeCount))
|
|
->createOne();
|
|
|
|
expect($series->anime())->toBeInstanceOf(BelongsToMany::class);
|
|
expect($series->anime()->count())->toEqual($animeCount);
|
|
expect($series->anime()->first())->toBeInstanceOf(Anime::class);
|
|
expect($series->anime()->getPivotClass())->toEqual(AnimeSeries::class);
|
|
});
|