Skip to content

A free open source IT asset/license management system

Improve naming and inline helper

Marcus Moore4c1aadd74e6a
diff --git a/tests/Feature/Notifications/AssetSlackTest.php b/tests/Feature/Notifications/AssetSlackTest.php
index d0b376c65c..c6d03df636 100644
--- a/tests/Feature/Notifications/AssetSlackTest.php
+++ b/tests/Feature/Notifications/AssetSlackTest.php
@@ -19,16 +19,16 @@ class AssetSlackTest extends TestCase
{
use InteractsWithSettings;
- public function targets(): array
+ public function assetCheckoutTargets(): array
{
return [
'Asset checked out to user' => [fn() => User::factory()->create()],
- 'Asset checked out to asset' => [fn() => $this->createAsset()],
+ 'Asset checked out to asset' => [fn() => Asset::factory()->laptopMbp()->create()],
'Asset checked out to location' => [fn() => Location::factory()->create()],
];
}
- /** @dataProvider targets */
+ /** @dataProvider assetCheckoutTargets */
public function testAssetCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{
Notification::fake();
@@ -36,7 +36,7 @@ class AssetSlackTest extends TestCase
$this->settings->enableSlackWebhook();
event(new CheckoutableCheckedOut(
- $this->createAsset(),
+ Asset::factory()->laptopMbp()->create(),
$checkoutTarget(),
User::factory()->superuser()->create(),
''
@@ -51,7 +51,7 @@ class AssetSlackTest extends TestCase
);
}
- /** @dataProvider targets */
+ /** @dataProvider assetCheckoutTargets */
public function testAssetCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{
Notification::fake();
@@ -59,7 +59,7 @@ class AssetSlackTest extends TestCase
$this->settings->disableSlackWebhook();
event(new CheckoutableCheckedOut(
- $this->createAsset(),
+ Asset::factory()->laptopMbp()->create(),
$checkoutTarget(),
User::factory()->superuser()->create(),
''
@@ -68,7 +68,7 @@ class AssetSlackTest extends TestCase
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAssetNotification::class);
}
- /** @dataProvider targets */
+ /** @dataProvider assetCheckoutTargets */
public function testAssetCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{
Notification::fake();
@@ -76,7 +76,7 @@ class AssetSlackTest extends TestCase
$this->settings->enableSlackWebhook();
event(new CheckoutableCheckedIn(
- $this->createAsset(),
+ Asset::factory()->laptopMbp()->create(),
$checkoutTarget(),
User::factory()->superuser()->create(),
''
@@ -91,7 +91,7 @@ class AssetSlackTest extends TestCase
);
}
- /** @dataProvider targets */
+ /** @dataProvider assetCheckoutTargets */
public function testAssetCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{
Notification::fake();
@@ -99,7 +99,7 @@ class AssetSlackTest extends TestCase
$this->settings->disableSlackWebhook();
event(new CheckoutableCheckedIn(
- $this->createAsset(),
+ Asset::factory()->laptopMbp()->create(),
$checkoutTarget(),
User::factory()->superuser()->create(),
''
@@ -107,9 +107,4 @@ class AssetSlackTest extends TestCase
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class);
}
-
- private function createAsset()
- {
- return Asset::factory()->laptopMbp()->create();
- }
}
diff --git a/tests/Feature/Notifications/LicenseSlackTest.php b/tests/Feature/Notifications/LicenseSlackTest.php
index c10fbdf5c3..8ed38c2788 100644
--- a/tests/Feature/Notifications/LicenseSlackTest.php
+++ b/tests/Feature/Notifications/LicenseSlackTest.php
@@ -19,7 +19,7 @@ class LicenseSlackTest extends TestCase
{
use InteractsWithSettings;
- public function targets(): array
+ public function licenseCheckoutTargets(): array
{
return [
'License checked out to user' => [fn() => User::factory()->create()],
@@ -27,7 +27,7 @@ class LicenseSlackTest extends TestCase
];
}
- /** @dataProvider targets */
+ /** @dataProvider licenseCheckoutTargets */
public function testLicenseCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{
Notification::fake();
@@ -50,7 +50,7 @@ class LicenseSlackTest extends TestCase
);
}
- /** @dataProvider targets */
+ /** @dataProvider licenseCheckoutTargets */
public function testLicenseCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{
Notification::fake();
@@ -67,7 +67,7 @@ class LicenseSlackTest extends TestCase
Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutLicenseSeatNotification::class);
}
- /** @dataProvider targets */
+ /** @dataProvider licenseCheckoutTargets */
public function testLicenseCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{
Notification::fake();
@@ -90,7 +90,7 @@ class LicenseSlackTest extends TestCase
);
}
- /** @dataProvider targets */
+ /** @dataProvider licenseCheckoutTargets */
public function testLicenseCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{
Notification::fake();