mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
2e930b17ff
* feat: initial migration to Laravel 10 * style: fix StyleCI findings
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Events\Pivot\Wiki;
|
|
|
|
use App\Events\Pivot\Wiki\StudioImage\StudioImageCreated;
|
|
use App\Events\Pivot\Wiki\StudioImage\StudioImageDeleted;
|
|
use App\Models\Wiki\Image;
|
|
use App\Models\Wiki\Studio;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class StudioImageTest.
|
|
*/
|
|
class StudioImageTest extends TestCase
|
|
{
|
|
/**
|
|
* When a Studio is attached to an Image or vice versa, a StudioImageCreated event shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testStudioImageCreatedEventDispatched(): void
|
|
{
|
|
$studio = Studio::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
$studio->images()->attach($image);
|
|
|
|
Event::assertDispatched(StudioImageCreated::class);
|
|
}
|
|
|
|
/**
|
|
* When a Studio is detached from an Image or vice versa, a StudioImageDeleted event shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testStudioImageDeletedEventDispatched(): void
|
|
{
|
|
$studio = Studio::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
$studio->images()->attach($image);
|
|
$studio->images()->detach($image);
|
|
|
|
Event::assertDispatched(StudioImageDeleted::class);
|
|
}
|
|
}
|