snipe-it/tests/Unit/NotificationTest.php
2021-12-02 15:08:26 -08:00

31 lines
904 B
PHP

<?php
namespace Tests\Unit;
use App\Models\User;
use App\Notifications\CheckoutAssetNotification;
use Illuminate\Support\Facades\Notification;
use Tests\Unit\BaseTest;
use Auth;
class NotificationTest extends BaseTest
{
/**
* @var \UnitTester
*/
protected $tester;
public 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();
Notification::fake();
$asset->checkOut($user, 1);
Notification::assertSentTo($user, CheckoutAssetNotification::class);
}
}