mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
Improve readability by extracting additional helpers
This commit is contained in:
parent
cd579a04dd
commit
d20844fefa
|
@ -58,13 +58,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckoutAccessoryNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckoutAccessoryNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessoryCheckoutDoesNotSendSlackNotificationWhenSettingDisabled()
|
public function testAccessoryCheckoutDoesNotSendSlackNotificationWhenSettingDisabled()
|
||||||
|
@ -76,7 +70,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAccessoryNotification::class);
|
$this->assertNoSlackNotificationSent(CheckoutAccessoryNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider assetCheckoutTargets */
|
/** @dataProvider assetCheckoutTargets */
|
||||||
|
@ -89,13 +83,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckoutAssetNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckoutAssetNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider assetCheckoutTargets */
|
/** @dataProvider assetCheckoutTargets */
|
||||||
|
@ -108,7 +96,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAssetNotification::class);
|
$this->assertNoSlackNotificationSent(CheckoutAssetNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testComponentCheckoutDoesNotSendSlackNotification()
|
public function testComponentCheckoutDoesNotSendSlackNotification()
|
||||||
|
@ -132,13 +120,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckoutConsumableNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckoutConsumableNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConsumableCheckoutDoesNotSendSlackNotificationWhenSettingDisabled()
|
public function testConsumableCheckoutDoesNotSendSlackNotificationWhenSettingDisabled()
|
||||||
|
@ -150,7 +132,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutConsumableNotification::class);
|
$this->assertNoSlackNotificationSent(CheckoutConsumableNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider licenseCheckoutTargets */
|
/** @dataProvider licenseCheckoutTargets */
|
||||||
|
@ -163,13 +145,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckoutLicenseSeatNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckoutLicenseSeatNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider licenseCheckoutTargets */
|
/** @dataProvider licenseCheckoutTargets */
|
||||||
|
@ -182,7 +158,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutLicenseSeatNotification::class);
|
$this->assertNoSlackNotificationSent(CheckoutLicenseSeatNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fireCheckOutEvent(Model $checkoutable, Model $target)
|
private function fireCheckOutEvent(Model $checkoutable, Model $target)
|
||||||
|
@ -194,4 +170,20 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
||||||
'',
|
'',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assertSlackNotificationSent(string $notificationClass)
|
||||||
|
{
|
||||||
|
Notification::assertSentTo(
|
||||||
|
new AnonymousNotifiable,
|
||||||
|
$notificationClass,
|
||||||
|
function ($notification, $channels, $notifiable) {
|
||||||
|
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertNoSlackNotificationSent(string $notificationClass)
|
||||||
|
{
|
||||||
|
Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue