mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-05 12:15:01 +02:00
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Constants\FeatureConstants;
|
|
use App\Events\Wiki\Video\VideoCreated;
|
|
use App\Events\Wiki\Video\VideoDeleted;
|
|
use App\Events\Wiki\Video\VideoRestored;
|
|
use App\Events\Wiki\Video\VideoUpdated;
|
|
use App\Jobs\SendDiscordNotificationJob;
|
|
use App\Models\Wiki\Video;
|
|
use Illuminate\Support\Facades\Bus;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Laravel\Pennant\Feature;
|
|
|
|
test('video created sends discord notification', function (): void {
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(VideoCreated::class);
|
|
|
|
Video::factory()->createOne();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
});
|
|
|
|
test('video deleted sends discord notification', function (): void {
|
|
$video = Video::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(VideoDeleted::class);
|
|
|
|
$video->delete();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
});
|
|
|
|
test('video restored sends discord notification', function (): void {
|
|
$video = Video::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(VideoRestored::class);
|
|
|
|
$video->restore();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
});
|
|
|
|
test('video updated sends discord notification', function (): void {
|
|
$video = Video::factory()->createOne();
|
|
|
|
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
Bus::fake(SendDiscordNotificationJob::class);
|
|
Event::fakeExcept(VideoUpdated::class);
|
|
|
|
$changes = Video::factory()->makeOne();
|
|
|
|
$video->fill($changes->getAttributes());
|
|
$video->save();
|
|
|
|
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
|
});
|