mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
922d6937ae
* There is no notes field on accessories. Fixes Importer Test. * Fix notification test. We should see a checkout not allowed exception when trying to check out to a location if the asset requires acceptance. * Fix Custom field import. Add a test for custom field import, and fix a few issues related to importing custom fields. This will restore v3 functionality. * Add UI support for mapping custom fields. This still requires the field mappings to be created/assigned in advance, but will fetch all custom field names and allow them to be selected when setting up custom field mappings. This commit also updates laravel-mix to v1.4.3 and other node dependencies to fix some build issues. * Fix some requestable asset page/assetloc issues. I'd love to know why laravel expections relationships to be in lower case... but thats a question for another day.
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
use App\Exceptions\CheckoutNotAllowed;
|
|
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();
|
|
|
|
$this->expectException(CheckoutNotAllowed::class);
|
|
$location = factory(Location::class)->create();
|
|
Notification::fake();
|
|
$asset->checkOut($location, 1);
|
|
|
|
Notification::assertNotSentTo($location, CheckoutNotification::class);
|
|
}
|
|
}
|