mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Feature\Notifications\Email;
|
||
|
|
||
|
use App\Events\CheckoutableCheckedIn;
|
||
|
use App\Models\Asset;
|
||
|
use App\Models\User;
|
||
|
use App\Notifications\CheckinAssetNotification;
|
||
|
use Illuminate\Support\Facades\Notification;
|
||
|
use Tests\Support\InteractsWithSettings;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class EmailNotificationsUponCheckinTest extends TestCase
|
||
|
{
|
||
|
use InteractsWithSettings;
|
||
|
|
||
|
public function testCheckInEmailSentToUserIfSettingEnabled()
|
||
|
{
|
||
|
Notification::fake();
|
||
|
|
||
|
$user = User::factory()->create();
|
||
|
$asset = Asset::factory()->assignedToUser($user)->create();
|
||
|
|
||
|
$asset->model->category->update(['checkin_email' => true]);
|
||
|
|
||
|
event(new CheckoutableCheckedIn(
|
||
|
$asset,
|
||
|
$user,
|
||
|
User::factory()->checkinAssets()->create(),
|
||
|
''
|
||
|
));
|
||
|
|
||
|
Notification::assertSentTo(
|
||
|
[$user],
|
||
|
function (CheckinAssetNotification $notification, $channels) {
|
||
|
return in_array('mail', $channels);
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function testCheckInEmailNotSentToUserIfSettingDisabled()
|
||
|
{
|
||
|
Notification::fake();
|
||
|
|
||
|
$user = User::factory()->create();
|
||
|
$asset = Asset::factory()->assignedToUser($user)->create();
|
||
|
|
||
|
$asset->model->category->update(['checkin_email' => false]);
|
||
|
|
||
|
event(new CheckoutableCheckedIn(
|
||
|
$asset,
|
||
|
$user,
|
||
|
User::factory()->checkinAssets()->create(),
|
||
|
''
|
||
|
));
|
||
|
|
||
|
Notification::assertNotSentTo(
|
||
|
[$user],
|
||
|
function (CheckinAssetNotification $notification, $channels) {
|
||
|
return in_array('mail', $channels);
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
}
|