mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-13 17:14:10 -08:00
Move notification test to notifications test suite
This commit is contained in:
parent
4354e126b1
commit
3cc72021b6
|
@ -120,14 +120,4 @@ class AssetCheckinTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCheckInEmailSentToUserIfSettingEnabled()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCheckInEmailNotSentToUserIfSettingDisabled()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,7 @@ use App\Models\LicenseSeat;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\CheckinAssetNotification;
|
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Notification;
|
|
||||||
use Tests\Support\InteractsWithSettings;
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -169,52 +167,4 @@ class AssetCheckinTest extends TestCase
|
||||||
return $event->action_date === '2023-01-02 12:45:56' && $event->note === 'hello';
|
return $event->action_date === '2023-01-02 12:45:56' && $event->note === 'hello';
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,54 @@ class AssetWebhookTest extends TestCase
|
||||||
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class);
|
Notification::assertNotSentTo(new AnonymousNotifiable, CheckinAssetNotification::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function createAsset()
|
private function createAsset()
|
||||||
{
|
{
|
||||||
return Asset::factory()->laptopMbp()->create();
|
return Asset::factory()->laptopMbp()->create();
|
||||||
|
|
Loading…
Reference in a new issue