A free open source IT asset/license management system
Migrate to new test settings interface
Marcus Mooref6cff908297e
diff --git a/tests/Feature/Notifications/AccessoryWebhookTest.php b/tests/Feature/Notifications/AccessoryWebhookTest.phpindex 8272202d8c..a1db59b985 100644--- a/tests/Feature/Notifications/AccessoryWebhookTest.php+++ b/tests/Feature/Notifications/AccessoryWebhookTest.php@@ -11,15 +11,18 @@ use App\Notifications\CheckinAccessoryNotification;use App\Notifications\CheckoutAccessoryNotification;use Illuminate\Notifications\AnonymousNotifiable;use Illuminate\Support\Facades\Notification;+use Tests\Support\InteractsWithSettings;use Tests\TestCase;class AccessoryWebhookTest extends TestCase{+ use InteractsWithSettings;+public function testAccessoryCheckoutSendsWebhookNotificationWhenSettingEnabled(){Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedOut(Accessory::factory()->appleBtKeyboard()->create(),@@ -41,7 +44,7 @@ class AccessoryWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedOut(Accessory::factory()->appleBtKeyboard()->create(),@@ -57,7 +60,7 @@ class AccessoryWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedIn(Accessory::factory()->appleBtKeyboard()->create(),@@ -79,7 +82,7 @@ class AccessoryWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedIn(Accessory::factory()->appleBtKeyboard()->create(),diff --git a/tests/Feature/Notifications/AssetWebhookTest.php b/tests/Feature/Notifications/AssetWebhookTest.phpindex 0e1ef9f201..c931b565a0 100644--- a/tests/Feature/Notifications/AssetWebhookTest.php+++ b/tests/Feature/Notifications/AssetWebhookTest.php@@ -13,10 +13,13 @@ use App\Notifications\CheckoutAssetNotification;use Illuminate\Notifications\AnonymousNotifiable;use Illuminate\Support\Facades\Event;use Illuminate\Support\Facades\Notification;+use Tests\Support\InteractsWithSettings;use Tests\TestCase;class AssetWebhookTest extends TestCase{+ use InteractsWithSettings;+public function checkoutTargets(): array{return [@@ -40,7 +43,7 @@ class AssetWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedOut($this->createAsset(),@@ -63,7 +66,7 @@ class AssetWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedOut($this->createAsset(),@@ -80,7 +83,7 @@ class AssetWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedIn($this->createAsset(),@@ -103,7 +106,7 @@ class AssetWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedIn($this->createAsset(),diff --git a/tests/Feature/Notifications/ConsumableWebhookTest.php b/tests/Feature/Notifications/ConsumableWebhookTest.phpindex ec3c0045a3..854fdf5341 100644--- a/tests/Feature/Notifications/ConsumableWebhookTest.php+++ b/tests/Feature/Notifications/ConsumableWebhookTest.php@@ -9,15 +9,18 @@ use App\Models\User;use App\Notifications\CheckoutConsumableNotification;use Illuminate\Notifications\AnonymousNotifiable;use Illuminate\Support\Facades\Notification;+use Tests\Support\InteractsWithSettings;use Tests\TestCase;class ConsumableWebhookTest extends TestCase{+ use InteractsWithSettings;+public function testConsumableCheckoutSendsWebhookNotificationWhenSettingEnabled(){Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedOut(Consumable::factory()->cardstock()->create(),@@ -39,7 +42,7 @@ class ConsumableWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedOut(Consumable::factory()->cardstock()->create(),diff --git a/tests/Feature/Notifications/LicenseWebhookTest.php b/tests/Feature/Notifications/LicenseWebhookTest.phpindex 9931f80a2c..da511d880f 100644--- a/tests/Feature/Notifications/LicenseWebhookTest.php+++ b/tests/Feature/Notifications/LicenseWebhookTest.php@@ -12,10 +12,13 @@ use App\Notifications\CheckinLicenseSeatNotification;use App\Notifications\CheckoutLicenseSeatNotification;use Illuminate\Notifications\AnonymousNotifiable;use Illuminate\Support\Facades\Notification;+use Tests\Support\InteractsWithSettings;use Tests\TestCase;class LicenseWebhookTest extends TestCase{+ use InteractsWithSettings;+public function checkoutTargets(): array{return [@@ -29,7 +32,7 @@ class LicenseWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedOut(LicenseSeat::factory()->create(),@@ -52,7 +55,7 @@ class LicenseWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedOut(LicenseSeat::factory()->create(),@@ -69,7 +72,7 @@ class LicenseWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookEnabled()->create();+ $this->settings->enableWebhook();event(new CheckoutableCheckedIn(LicenseSeat::factory()->create(),@@ -92,7 +95,7 @@ class LicenseWebhookTest extends TestCase{Notification::fake();- Setting::factory()->withWebhookDisabled()->create();+ $this->settings->disableWebhook();event(new CheckoutableCheckedIn(LicenseSeat::factory()->create(),diff --git a/tests/Support/Settings.php b/tests/Support/Settings.phpindex ccf50c3ce3..9d4209da79 100644--- a/tests/Support/Settings.php+++ b/tests/Support/Settings.php@@ -23,6 +23,24 @@ class Settingsreturn $this->update(['full_multiple_companies_support' => 1]);}+ public function enableWebhook(): Settings+ {+ return $this->update([+ 'webhook_botname' => 'SnipeBot5000',+ 'webhook_endpoint' => 'https://hooks.slack.com/services/NZ59/Q446/672N',+ 'webhook_channel' => '#it',+ ]);+ }++ public function disableWebhook(): Settings+ {+ return $this->update([+ 'webhook_botname' => '',+ 'webhook_endpoint' => '',+ 'webhook_channel' => '',+ ]);+ }+/*** @param array $attributes Attributes to modify in the application's settings.*/