mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-28 01:34:43 +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
97 lines
2.7 KiB
PHP
97 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Jobs\Wiki;
|
|
|
|
use App\Constants\FeatureConstants;
|
|
use App\Events\Wiki\Artist\ArtistCreated;
|
|
use App\Events\Wiki\Artist\ArtistDeleted;
|
|
use App\Events\Wiki\Artist\ArtistRestored;
|
|
use App\Events\Wiki\Artist\ArtistUpdated;
|
|
use App\Jobs\SendDiscordNotificationJob;
|
|
use App\Models\Wiki\Artist;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Laravel\Pennant\Feature;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class ArtistTest.
|
|
*/
|
|
class ArtistTest extends TestCase
|
|
{
|
|
/**
|
|
* When an artist is created, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistCreatedSendsDiscordNotification(): void
|
|
{
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(ArtistCreated::class);
|
|
|
|
Artist::factory()->createOne();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
|
|
/**
|
|
* When an artist is deleted, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistDeletedSendsDiscordNotification(): void
|
|
{
|
|
$artist = Artist::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(ArtistDeleted::class);
|
|
|
|
$artist->delete();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
|
|
/**
|
|
* When an artist is restored, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistRestoredSendsDiscordNotification(): void
|
|
{
|
|
$artist = Artist::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(ArtistRestored::class);
|
|
|
|
$artist->restore();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
|
|
/**
|
|
* When an artist is updated, a SendDiscordNotification job shall be dispatched.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testArtistUpdatedSendsDiscordNotification(): void
|
|
{
|
|
$artist = Artist::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(ArtistUpdated::class);
|
|
|
|
$changes = Artist::factory()->makeOne();
|
|
|
|
$artist->fill($changes->getAttributes());
|
|
$artist->save();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
}
|
|
}
|