Skip to content

A free open source IT asset/license management system

Implement test

Marcus Moore3670efacb4e7
diff --git a/tests/Feature/Notifications/Webhooks/WebhookNotificationsUponBulkAssetCheckoutTest.php b/tests/Feature/Notifications/Webhooks/WebhookNotificationsUponBulkAssetCheckoutTest.php
index 5f94891a7d..57f97fc48d 100644
--- a/tests/Feature/Notifications/Webhooks/WebhookNotificationsUponBulkAssetCheckoutTest.php
+++ b/tests/Feature/Notifications/Webhooks/WebhookNotificationsUponBulkAssetCheckoutTest.php
@@ -2,7 +2,6 @@
namespace Tests\Feature\Notifications\Webhooks;
-use App\Events\CheckoutablesCheckedOutInBulk;
use App\Models\Asset;
use App\Models\User;
use App\Notifications\CheckoutAssetNotification;
@@ -13,30 +12,26 @@ class WebhookNotificationsUponBulkAssetCheckoutTest extends TestCase
{
public function test_webbook_is_sent_upon_bulk_asset_checkout()
{
- $this->markTestIncomplete();
-
Notification::fake();
$this->settings->enableSlackWebhook();
$assets = Asset::factory()->requiresAcceptance()->count(2)->create();
- $target = User::factory()->create(['email' => '[email protected]']);
- $admin = User::factory()->create();
- $checkout_at = date('Y-m-d H:i:s');
- $expected_checkin = '';
-
- CheckoutablesCheckedOutInBulk::dispatch(
- $assets,
- $target,
- $admin,
- $checkout_at,
- $expected_checkin,
- 'A note here',
- );
-
- Notification::assertNothingSentTo(CheckoutAssetNotification::class);
- Notification::assertSentTimes(BulkAssetCheckoutNotification::class, 1);
- $this->assertSlackNotificationSent(BulkAssetCheckoutNotification::class);
+ $this->actingAs(User::factory()->checkoutAssets()->viewAssets()->create())
+ ->followingRedirects()
+ ->post(route('hardware.bulkcheckout.store'), [
+ 'selected_assets' => $assets->pluck('id')->toArray(),
+ 'checkout_to_type' => 'user',
+ 'assigned_user' => User::factory()->create(['email' => '[email protected]'])->id,
+ 'assigned_asset' => null,
+ 'checkout_at' => now()->subWeek()->format('Y-m-d'),
+ 'expected_checkin' => now()->addWeek()->format('Y-m-d'),
+ 'note' => null,
+ ])
+ ->assertOk();
+
+ $this->assertSlackNotificationSent(CheckoutAssetNotification::class);
+ Notification::assertSentTimes(CheckoutAssetNotification::class, 2);
}
}