mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
ad07aa3703
* feat: support images for studios * style: fix StyleCI findings * fix(admin): throw exception for image request * style: fix StyleCI findings * style: remove extraneous constant * fix(admin): resources mapping may not exist when sending pipe notification * style: fix StyleCI findings
133 lines
3.5 KiB
PHP
133 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Models\Wiki;
|
|
|
|
use App\Models\Wiki\Anime;
|
|
use App\Models\Wiki\ExternalResource;
|
|
use App\Models\Wiki\Image;
|
|
use App\Models\Wiki\Studio;
|
|
use App\Pivots\AnimeStudio;
|
|
use App\Pivots\StudioImage;
|
|
use App\Pivots\StudioResource;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class StudioTest.
|
|
*/
|
|
class StudioTest extends TestCase
|
|
{
|
|
use WithFaker;
|
|
|
|
/**
|
|
* Studio shall be a searchable resource.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testSearchableAs(): void
|
|
{
|
|
$studio = Studio::factory()->createOne();
|
|
|
|
static::assertIsString($studio->searchableAs());
|
|
}
|
|
|
|
/**
|
|
* Studio shall be a searchable resource.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testToSearchableArray(): void
|
|
{
|
|
$studio = Studio::factory()->createOne();
|
|
|
|
static::assertIsArray($studio->toSearchableArray());
|
|
}
|
|
|
|
/**
|
|
* Studio shall be auditable.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAuditable(): void
|
|
{
|
|
Config::set('audit.console', true);
|
|
|
|
$studio = Studio::factory()->createOne();
|
|
|
|
static::assertEquals(1, $studio->audits()->count());
|
|
}
|
|
|
|
/**
|
|
* Studio shall be nameable.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testNameable(): void
|
|
{
|
|
$studio = Studio::factory()->createOne();
|
|
|
|
static::assertIsString($studio->getName());
|
|
}
|
|
|
|
/**
|
|
* Studio shall have a many-to-many relationship with the type Anime.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAnime(): void
|
|
{
|
|
$animeCount = $this->faker->randomDigitNotNull();
|
|
|
|
$studio = Studio::factory()
|
|
->has(Anime::factory()->count($animeCount))
|
|
->createOne();
|
|
|
|
static::assertInstanceOf(BelongsToMany::class, $studio->anime());
|
|
static::assertEquals($animeCount, $studio->anime()->count());
|
|
static::assertInstanceOf(Anime::class, $studio->anime()->first());
|
|
static::assertEquals(AnimeStudio::class, $studio->anime()->getPivotClass());
|
|
}
|
|
|
|
/**
|
|
* Studio shall have a many-to-many relationship with the type ExternalResource.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testExternalResources(): void
|
|
{
|
|
$resourceCount = $this->faker->randomDigitNotNull();
|
|
|
|
$studio = Studio::factory()
|
|
->has(ExternalResource::factory()->count($resourceCount), 'resources')
|
|
->createOne();
|
|
|
|
static::assertInstanceOf(BelongsToMany::class, $studio->resources());
|
|
static::assertEquals($resourceCount, $studio->resources()->count());
|
|
static::assertInstanceOf(ExternalResource::class, $studio->resources()->first());
|
|
static::assertEquals(StudioResource::class, $studio->resources()->getPivotClass());
|
|
}
|
|
|
|
/**
|
|
* Studio shall have a many-to-many relationship with the type Image.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testImages(): void
|
|
{
|
|
$imageCount = $this->faker->randomDigitNotNull();
|
|
|
|
$studio = Studio::factory()
|
|
->has(Image::factory()->count($imageCount))
|
|
->createOne();
|
|
|
|
static::assertInstanceOf(BelongsToMany::class, $studio->images());
|
|
static::assertEquals($imageCount, $studio->images()->count());
|
|
static::assertInstanceOf(Image::class, $studio->images()->first());
|
|
static::assertEquals(StudioImage::class, $studio->images()->getPivotClass());
|
|
}
|
|
}
|