mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Cleanup
This commit is contained in:
parent
02f6aa6161
commit
dbc79655b0
|
@ -17,24 +17,24 @@ class EmailNotificationsUponCheckinTest extends TestCase
|
||||||
{
|
{
|
||||||
use InteractsWithSettings;
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Notification::fake();
|
||||||
|
}
|
||||||
|
|
||||||
public function testCheckInEmailSentToUserIfSettingEnabled()
|
public function testCheckInEmailSentToUserIfSettingEnabled()
|
||||||
{
|
{
|
||||||
Notification::fake();
|
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
$asset = Asset::factory()->assignedToUser($user)->create();
|
$asset = Asset::factory()->assignedToUser($user)->create();
|
||||||
|
|
||||||
$asset->model->category->update(['checkin_email' => true]);
|
$asset->model->category->update(['checkin_email' => true]);
|
||||||
|
|
||||||
event(new CheckoutableCheckedIn(
|
$this->fireCheckInEvent($asset, $user);
|
||||||
$asset,
|
|
||||||
$user,
|
|
||||||
User::factory()->checkinAssets()->create(),
|
|
||||||
''
|
|
||||||
));
|
|
||||||
|
|
||||||
Notification::assertSentTo(
|
Notification::assertSentTo(
|
||||||
[$user],
|
$user,
|
||||||
function (CheckinAssetNotification $notification, $channels) {
|
function (CheckinAssetNotification $notification, $channels) {
|
||||||
return in_array('mail', $channels);
|
return in_array('mail', $channels);
|
||||||
},
|
},
|
||||||
|
@ -43,25 +43,28 @@ class EmailNotificationsUponCheckinTest extends TestCase
|
||||||
|
|
||||||
public function testCheckInEmailNotSentToUserIfSettingDisabled()
|
public function testCheckInEmailNotSentToUserIfSettingDisabled()
|
||||||
{
|
{
|
||||||
Notification::fake();
|
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
$asset = Asset::factory()->assignedToUser($user)->create();
|
$asset = Asset::factory()->assignedToUser($user)->create();
|
||||||
|
|
||||||
$asset->model->category->update(['checkin_email' => false]);
|
$asset->model->category->update(['checkin_email' => false]);
|
||||||
|
|
||||||
|
$this->fireCheckInEvent($asset, $user);
|
||||||
|
|
||||||
|
Notification::assertNotSentTo(
|
||||||
|
$user,
|
||||||
|
function (CheckinAssetNotification $notification, $channels) {
|
||||||
|
return in_array('mail', $channels);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fireCheckInEvent($asset, $user): void
|
||||||
|
{
|
||||||
event(new CheckoutableCheckedIn(
|
event(new CheckoutableCheckedIn(
|
||||||
$asset,
|
$asset,
|
||||||
$user,
|
$user,
|
||||||
User::factory()->checkinAssets()->create(),
|
User::factory()->checkinAssets()->create(),
|
||||||
''
|
''
|
||||||
));
|
));
|
||||||
|
|
||||||
Notification::assertNotSentTo(
|
|
||||||
[$user],
|
|
||||||
function (CheckinAssetNotification $notification, $channels) {
|
|
||||||
return in_array('mail', $channels);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue