mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-24 19:49:24 +02:00
* feat: initial commit for feature management * style: fix StyleCI findings * fix(api): prohibit features of nonnull scope from API & fix(admin): wrong translate key * style: fix Static Analysis error
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Jobs\Pivot\Wiki;
|
|
|
|
use App\Constants\FeatureConstants;
|
|
use App\Events\Pivot\Wiki\AnimeImage\AnimeImageCreated;
|
|
use App\Events\Pivot\Wiki\AnimeImage\AnimeImageDeleted;
|
|
use App\Jobs\SendDiscordNotificationJob;
|
|
use App\Models\Wiki\Anime;
|
|
use App\Models\Wiki\Image;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Laravel\Pennant\Feature;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class AnimeImageTest.
|
|
*/
|
|
class AnimeImageTest extends TestCase
|
|
{
|
|
/**
|
|
* When an Anime is attached to an Image or vice versa, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAnimeImageCreatedSendsDiscordNotification(): void
|
|
{
|
|
$anime = Anime::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(AnimeImageCreated::class);
|
|
|
|
$anime->images()->attach($image);
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
|
|
/**
|
|
* When an Anime is detached from an Image or vice versa, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAnimeImageDeletedSendsDiscordNotification(): void
|
|
{
|
|
$anime = Anime::factory()->createOne();
|
|
$image = Image::factory()->createOne();
|
|
|
|
$anime->images()->attach($image);
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(AnimeImageDeleted::class);
|
|
|
|
$anime->images()->detach($image);
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
}
|