Improve naming and inline helper

This commit is contained in:
Marcus Moore 2024-02-27 17:09:22 -08:00
parent 7d3719bf70
commit 4c1aadd74e
No known key found for this signature in database
2 changed files with 15 additions and 20 deletions

View file

@ -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();
}
}

View file

@ -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();