mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Implement tests for webhook notifications on accessory checkout
This commit is contained in:
parent
b2292db3c8
commit
524249d4d7
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Notifications;
|
||||
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckoutAccessoryNotification;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AccessoryCheckoutWebhookNotificationTest extends TestCase
|
||||
{
|
||||
public function testWebhookNotificationsAreSentOnAccessoryCheckoutWhenWebhookSettingEnabled()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
Setting::factory()->withWebhookEnabled()->create();
|
||||
|
||||
event(new CheckoutableCheckedOut(
|
||||
Accessory::factory()->appleBtKeyboard()->create(),
|
||||
User::factory()->create(),
|
||||
User::factory()->superuser()->create(),
|
||||
''
|
||||
));
|
||||
|
||||
Notification::assertSentTo(
|
||||
new AnonymousNotifiable,
|
||||
CheckoutAccessoryNotification::class,
|
||||
function ($notification, $channels, $notifiable) {
|
||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testWebhookNotificationsAreNotSentOnAccessoryCheckoutWhenWebhookSettingNotEnabled()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
Setting::factory()->withWebhookDisabled()->create();
|
||||
|
||||
event(new CheckoutableCheckedOut(
|
||||
Accessory::factory()->appleBtKeyboard()->create(),
|
||||
User::factory()->create(),
|
||||
User::factory()->superuser()->create(),
|
||||
''
|
||||
));
|
||||
|
||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAccessoryNotification::class);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue