A free open source IT asset/license management system
Fixed notification tests
snipef334bf105832
diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.phpindex c8acd65f11..93d16ff5bc 100644--- a/app/Listeners/CheckoutableListener.php+++ b/app/Listeners/CheckoutableListener.php@@ -135,7 +135,7 @@ class CheckoutableListener/*** Notify Admin users if the settings is activated*/- if (Setting::getSettings()->admin_cc_email != '') {+ if ((Setting::getSettings()) && (Setting::getSettings()->admin_cc_email != '')) {$notifiables->push(new AdminRecipient());}diff --git a/app/Notifications/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.phpindex 44708220aa..c56c1a3711 100644--- a/app/Notifications/CheckoutAssetNotification.php+++ b/app/Notifications/CheckoutAssetNotification.php@@ -53,7 +53,7 @@ class CheckoutAssetNotification extends Notification{$notifyBy = [];- if (Setting::getSettings()->slack_endpoint != '') {+ if ((Setting::getSettings()) && (Setting::getSettings()->slack_endpoint != '')) {\Log::debug('use slack');$notifyBy[] = 'slack';}diff --git a/tests/Unit/NotificationTest.php b/tests/Unit/NotificationTest.phpindex 83296196c8..509aee6845 100644--- a/tests/Unit/NotificationTest.php+++ b/tests/Unit/NotificationTest.php@@ -2,10 +2,14 @@namespace Tests\Unit;use App\Models\User;+use App\Models\Asset;+use App\Models\AssetModel;+use App\Models\Category;+use Carbon\Carbon;use App\Notifications\CheckoutAssetNotification;use Illuminate\Support\Facades\Notification;use Tests\Unit\BaseTest;-use Auth;+class NotificationTest extends BaseTest{@@ -16,15 +20,24 @@ class NotificationTest extends BaseTestpublic function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA(){- $admin = User::factory()->superuser()->create();- Auth::login($admin);- $cat = $this->createValidCategory('asset-laptop-category', ['require_acceptance' => true]);- $model = $this->createValidAssetModel('mbp-13-model', ['category_id' => $cat->id]);- $asset = $this->createValidAsset(['model_id' => $model->id]);- $user = $this->createValidUser();+ $user = User::factory()->create();+ $asset = Asset::factory()+ ->create(+ [+ 'model_id' => AssetModel::factory()+ ->create(+ [+ 'category_id' => Category::factory()->assetLaptopCategory()->id+ ]+ )->id,+ 'warranty_months' => 24,+ 'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)+ ]);++ //dd($asset);Notification::fake();- $asset->checkOut($user, 1);+ $asset->checkOut($user, $asset->id);Notification::assertSentTo($user, CheckoutAssetNotification::class);}}