mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Improve readability by extracting additional helpers
This commit is contained in:
parent
bf32ab177f
commit
bd4d3aa52b
|
@ -56,13 +56,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckinAccessoryNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckinAccessoryNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAccessoryCheckinDoesNotSendSlackNotificationWhenSettingDisabled()
|
public function testAccessoryCheckinDoesNotSendSlackNotificationWhenSettingDisabled()
|
||||||
|
@ -74,7 +68,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
User::factory()->create(),
|
User::factory()->create(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAccessoryNotification::class);
|
$this->assertNoSlackNotificationSent(CheckinAccessoryNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider assetCheckoutTargets */
|
/** @dataProvider assetCheckoutTargets */
|
||||||
|
@ -87,13 +81,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckinAssetNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckinAssetNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider assetCheckoutTargets */
|
/** @dataProvider assetCheckoutTargets */
|
||||||
|
@ -106,7 +94,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class);
|
$this->assertNoSlackNotificationSent(CheckinAssetNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testComponentCheckinDoesNotSendSlackNotification()
|
public function testComponentCheckinDoesNotSendSlackNotification()
|
||||||
|
@ -141,13 +129,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
$this->assertSlackNotificationSent(CheckinLicenseSeatNotification::class);
|
||||||
new AnonymousNotifiable,
|
|
||||||
CheckinLicenseSeatNotification::class,
|
|
||||||
function ($notification, $channels, $notifiable) {
|
|
||||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @dataProvider licenseCheckoutTargets */
|
/** @dataProvider licenseCheckoutTargets */
|
||||||
|
@ -160,7 +142,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
||||||
$checkoutTarget(),
|
$checkoutTarget(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinLicenseSeatNotification::class);
|
$this->assertNoSlackNotificationSent(CheckinLicenseSeatNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fireCheckInEvent(Model $checkoutable, Model $target)
|
private function fireCheckInEvent(Model $checkoutable, Model $target)
|
||||||
|
@ -172,4 +154,20 @@ class SlackNotificationsUponCheckinTest 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, CheckinAccessoryNotification::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue