mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-25 11:09:17 +01: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\AnimeSeries\AnimeSeriesCreated;
|
|
use App\Events\Pivot\Wiki\AnimeSeries\AnimeSeriesDeleted;
|
|
use App\Jobs\SendDiscordNotificationJob;
|
|
use App\Models\Wiki\Anime;
|
|
use App\Models\Wiki\Series;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Laravel\Pennant\Feature;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class AnimeSeriesTest.
|
|
*/
|
|
class AnimeSeriesTest extends TestCase
|
|
{
|
|
/**
|
|
* When an Anime is attached to a Series or vice versa, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAnimeSeriesCreatedSendsDiscordNotification(): void
|
|
{
|
|
$anime = Anime::factory()->createOne();
|
|
$series = Series::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(AnimeSeriesCreated::class);
|
|
|
|
$anime->series()->attach($series);
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
|
|
/**
|
|
* When an Anime is detached from a Series or vice versa, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testAnimeSeriesDeletedSendsDiscordNotification(): void
|
|
{
|
|
$anime = Anime::factory()->createOne();
|
|
$series = Series::factory()->createOne();
|
|
|
|
$anime->series()->attach($series);
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(AnimeSeriesDeleted::class);
|
|
|
|
$anime->series()->detach($series);
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
}
|