2017-08-31 11:14:21 -07:00
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests\Unit;
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2017-08-31 11:14:21 -07:00
|
|
|
use App\Models\User;
|
2018-03-25 13:46:57 -07:00
|
|
|
use App\Notifications\CheckoutAssetNotification;
|
2017-08-31 11:14:21 -07:00
|
|
|
use Illuminate\Support\Facades\Notification;
|
2021-11-30 20:09:29 -08:00
|
|
|
use Tests\Unit\BaseTest;
|
2021-12-01 23:33:20 -08:00
|
|
|
use Auth;
|
2017-08-31 11:14:21 -07:00
|
|
|
|
|
|
|
class NotificationTest extends BaseTest
|
|
|
|
{
|
|
|
|
/**
|
2021-06-10 13:15:52 -07:00
|
|
|
* @var \UnitTester
|
|
|
|
*/
|
2017-08-31 11:14:21 -07:00
|
|
|
protected $tester;
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
|
|
|
{
|
2021-06-10 13:17:44 -07:00
|
|
|
$admin = User::factory()->superuser()->create();
|
2020-04-27 18:02:14 -07:00
|
|
|
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();
|
2017-08-31 11:14:21 -07:00
|
|
|
|
2020-04-27 18:02:14 -07:00
|
|
|
Notification::fake();
|
|
|
|
$asset->checkOut($user, 1);
|
|
|
|
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2017-08-31 11:14:21 -07:00
|
|
|
}
|