mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Test the event instead of the checkout
This commit is contained in:
parent
2cbc6276f7
commit
158e1544cd
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace Tests\Feature\Notifications;
|
||||
|
||||
use App\Events\CheckoutableCheckedOut;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckoutAssetNotification;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -22,6 +24,15 @@ class AssetCheckoutWebhookNotificationTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
public function testAssetCheckoutFiresCheckoutEvent()
|
||||
{
|
||||
Event::fake([CheckoutableCheckedOut::class]);
|
||||
|
||||
$this->createAsset()->checkOut(User::factory()->create(), User::factory()->create());
|
||||
|
||||
Event::assertDispatched(CheckoutableCheckedOut::class);
|
||||
}
|
||||
|
||||
/** @dataProvider checkoutTargets */
|
||||
public function testWebhookNotificationsAreSentOnAssetCheckoutWhenWebhookSettingEnabled($checkoutTarget)
|
||||
{
|
||||
|
@ -29,10 +40,12 @@ class AssetCheckoutWebhookNotificationTest extends TestCase
|
|||
|
||||
Setting::factory()->withWebhookEnabled()->create();
|
||||
|
||||
$this->createAsset()->checkOut(
|
||||
event(new CheckoutableCheckedOut(
|
||||
$this->createAsset(),
|
||||
$checkoutTarget(),
|
||||
User::factory()->superuser()->create()->id
|
||||
);
|
||||
User::factory()->superuser()->create(),
|
||||
''
|
||||
));
|
||||
|
||||
Notification::assertSentTo(
|
||||
new AnonymousNotifiable,
|
||||
|
@ -48,10 +61,12 @@ class AssetCheckoutWebhookNotificationTest extends TestCase
|
|||
{
|
||||
Notification::fake();
|
||||
|
||||
$this->createAsset()->checkOut(
|
||||
event(new CheckoutableCheckedOut(
|
||||
$this->createAsset(),
|
||||
$checkoutTarget(),
|
||||
User::factory()->superuser()->create()->id
|
||||
);
|
||||
User::factory()->superuser()->create(),
|
||||
''
|
||||
));
|
||||
|
||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAssetNotification::class);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue