mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Migrate to new test settings interface
This commit is contained in:
parent
2d56675ade
commit
f6cff90829
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -23,6 +23,24 @@ class Settings
|
|||
return $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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue