Files
animethemes-server/tests/Feature/Events/Pivot/List/PlaylistImageTest.php
T
paranarimasu 2e930b17ff feat: initial migration to Laravel 10 (#572)
* feat: initial migration to Laravel 10

* style: fix StyleCI findings
2023-04-18 16:22:36 -05:00

50 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Events\Pivot\List;
use App\Events\Pivot\List\PlaylistImage\PlaylistImageCreated;
use App\Events\Pivot\List\PlaylistImage\PlaylistImageDeleted;
use App\Models\List\Playlist;
use App\Models\Wiki\Image;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
/**
* Class PlaylistImageTest.
*/
class PlaylistImageTest extends TestCase
{
/**
* When a Playlist is attached to an Image or vice versa, a PlaylistImageCreated event shall be dispatched.
*
* @return void
*/
public function testPlaylistImageCreatedEventDispatched(): void
{
$playlist = Playlist::factory()->createOne();
$image = Image::factory()->createOne();
$playlist->images()->attach($image);
Event::assertDispatched(PlaylistImageCreated::class);
}
/**
* When a Playlist is detached from an Image or vice versa, a PlaylistImageDeleted event shall be dispatched.
*
* @return void
*/
public function testPlaylistImageDeletedEventDispatched(): void
{
$playlist = Playlist::factory()->createOne();
$image = Image::factory()->createOne();
$playlist->images()->attach($image);
$playlist->images()->detach($image);
Event::assertDispatched(PlaylistImageDeleted::class);
}
}