mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-25 08:14:29 +02: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;
|
|
|
|
uses(WithFaker::class);
|
|
|
|
test('searchable as', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
$this->assertIsString($series->searchableAs());
|
|
});
|
|
|
|
test('to searchable array', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
$this->assertIsArray($series->toSearchableArray());
|
|
});
|
|
|
|
test('nameable', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
$this->assertIsString($series->getName());
|
|
});
|
|
|
|
test('has subtitle', function (): void {
|
|
$series = Series::factory()->createOne();
|
|
|
|
$this->assertIsString($series->getSubtitle());
|
|
});
|
|
|
|
test('anime', function (): void {
|
|
$animeCount = fake()->randomDigitNotNull();
|
|
|
|
$series = Series::factory()
|
|
->has(Anime::factory()->count($animeCount))
|
|
->createOne();
|
|
|
|
$this->assertInstanceOf(BelongsToMany::class, $series->anime());
|
|
$this->assertEquals($animeCount, $series->anime()->count());
|
|
$this->assertInstanceOf(Anime::class, $series->anime()->first());
|
|
$this->assertEquals(AnimeSeries::class, $series->anime()->getPivotClass());
|
|
});
|