From 4c1aadd74e6aa43d13e7d96ee833abffa6de8d21 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 27 Feb 2024 17:09:22 -0800 Subject: [PATCH] Improve naming and inline helper --- .../Feature/Notifications/AssetSlackTest.php | 25 ++++++++----------- .../Notifications/LicenseSlackTest.php | 10 ++++---- 2 files changed, 15 insertions(+), 20 deletions(-) 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();