
Working mail from notification. Still requires testing/cleaning Add tests around checkout notification. This also removes the ability to check out an asset to a location|asset that requires acceptance/a Eula. For 4.1 we may think about how to support such a thing, but at present it seems to make sense to only alow such assets to be checked out to users, who can be responsible for the items.
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
use App\Models\Asset;
|
|
use App\Models\AssetModel;
|
|
use App\Models\Category;
|
|
use App\Models\Location;
|
|
use App\Models\User;
|
|
use App\Notifications\CheckoutNotification;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
class NotificationTest extends BaseTest
|
|
{
|
|
/**
|
|
* @var \UnitTester
|
|
*/
|
|
protected $tester;
|
|
|
|
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
|
{
|
|
$admin = factory(User::class)->states('superuser')->create();
|
|
Auth::login($admin);
|
|
$cat = factory(Category::class)->states('asset-category', 'requires-acceptance')->create();
|
|
$model = factory(AssetModel::class)->create(['category_id' => $cat->id]);
|
|
$asset = factory(Asset::class)->create(['model_id' => $model->id]);
|
|
|
|
$user = factory(User::class)->create();
|
|
Notification::fake();
|
|
$asset->checkOut($user, 1);
|
|
|
|
Notification::assertSentTo($user, CheckoutNotification::class);
|
|
}
|
|
|
|
public function testAnAssetRequiringAEulaDoesNotExplodeWhenCheckedOutToALocation()
|
|
{
|
|
$this->signIn();
|
|
$asset = factory(Asset::class)->states('requires-acceptance')->create();
|
|
|
|
$location = factory(Location::class)->create();
|
|
Notification::fake();
|
|
$asset->checkOut($location, 1);
|
|
|
|
Notification::assertNotSentTo($location, CheckoutNotification::class);
|
|
}
|
|
}
|