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\ArtistImage\ArtistImageCreated;
|
|
use App\Events\Pivot\Wiki\ArtistImage\ArtistImageDeleted;
|
|
use App\Models\Wiki\Artist;
|
|
use App\Models\Wiki\Image;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class ArtistImageTest.
|
|
*/
|
|
class ArtistImageTest extends TestCase
|
|
{
|
|
/**
|
|
* When an Artist is attached to an Image or vice versa, an ArtistImageCreated event shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistImageCreatedEventDispatched(): void
|
|
{
|
|
$artist = Artist::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
$artist->images()->attach($image);
|
|
|
|
Event::assertDispatched(ArtistImageCreated::class);
|
|
}
|
|
|
|
/**
|
|
* When an Artist is detached from an Image or vice versa, an ArtistImageDeleted event shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistImageDeletedEventDispatched(): void
|
|
{
|
|
$artist = Artist::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
$artist->images()->attach($image);
|
|
$artist->images()->detach($image);
|
|
|
|
Event::assertDispatched(ArtistImageDeleted::class);
|
|
}
|
|
}
|