mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
Clean up test code
This commit is contained in:
parent
66224765ea
commit
28ced46b9d
|
@ -17,14 +17,13 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
Setting::factory()->withWebhookEnabled()->create();
|
$this->enableWebhookSettings();
|
||||||
|
|
||||||
$asset = Asset::factory()->laptopMbp()->create();
|
$user = $this->createUser();
|
||||||
$user = User::factory()->create();
|
|
||||||
|
|
||||||
$asset->checkOut(
|
$this->createAsset()->checkOut(
|
||||||
$user,
|
$user,
|
||||||
User::factory()->superuser()->create()->id
|
$this->createSuperUser()->id
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertSentTo(
|
Notification::assertSentTo(
|
||||||
|
@ -40,12 +39,11 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
Setting::factory()->withWebhookEnabled()->create();
|
$this->enableWebhookSettings();
|
||||||
|
|
||||||
$assetBeingCheckedOut = Asset::factory()->laptopMbp()->create();
|
$this->createAsset()->checkOut(
|
||||||
$assetBeingCheckedOut->checkOut(
|
$this->createAsset(),
|
||||||
Asset::factory()->laptopMbp()->create(),
|
$this->createSuperUser()->id
|
||||||
User::factory()->superuser()->create()->id
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Since the target is not a user with an email address we have
|
// Since the target is not a user with an email address we have
|
||||||
|
@ -63,10 +61,9 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
$assetBeingCheckedOut = Asset::factory()->laptopMbp()->create();
|
$this->createAsset()->checkOut(
|
||||||
$assetBeingCheckedOut->checkOut(
|
$this->createAsset(),
|
||||||
Asset::factory()->laptopMbp()->create(),
|
$this->createSuperUser()->id
|
||||||
User::factory()->superuser()->create()->id
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(
|
Notification::assertNotSentTo(
|
||||||
|
@ -79,12 +76,11 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
Setting::factory()->withWebhookEnabled()->create();
|
$this->enableWebhookSettings();
|
||||||
|
|
||||||
$asset = Asset::factory()->laptopMbp()->create();
|
$this->createAsset()->checkOut(
|
||||||
$asset->checkOut(
|
|
||||||
Location::factory()->create(),
|
Location::factory()->create(),
|
||||||
User::factory()->superuser()->create()->id
|
$this->createSuperUser()->id
|
||||||
);
|
);
|
||||||
|
|
||||||
// Since the target is not a user with an email address we have
|
// Since the target is not a user with an email address we have
|
||||||
|
@ -102,10 +98,9 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
$asset = Asset::factory()->laptopMbp()->create();
|
$this->createAsset()->checkOut(
|
||||||
$asset->checkOut(
|
|
||||||
Location::factory()->create(),
|
Location::factory()->create(),
|
||||||
User::factory()->superuser()->create()->id
|
$this->createSuperUser()->id
|
||||||
);
|
);
|
||||||
|
|
||||||
Notification::assertNotSentTo(
|
Notification::assertNotSentTo(
|
||||||
|
@ -113,4 +108,24 @@ class AssetCheckoutSlackNotificationTest extends TestCase
|
||||||
CheckoutAssetNotification::class,
|
CheckoutAssetNotification::class,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function enableWebhookSettings()
|
||||||
|
{
|
||||||
|
Setting::factory()->withWebhookEnabled()->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createAsset()
|
||||||
|
{
|
||||||
|
return Asset::factory()->laptopMbp()->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createUser()
|
||||||
|
{
|
||||||
|
return User::factory()->create();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createSuperUser()
|
||||||
|
{
|
||||||
|
return User::factory()->superuser()->create();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue