mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-23 12:44:12 -08:00
attempt to fix tests
This commit is contained in:
parent
123cdeb858
commit
dceb8e305f
|
@ -3,10 +3,12 @@
|
|||
namespace Tests\Feature\Checkins\Ui;
|
||||
|
||||
use App\Events\CheckoutableCheckedIn;
|
||||
use App\Mail\CheckoutAccessoryMail;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckinAccessoryNotification;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -40,7 +42,7 @@ class AccessoryCheckinTest extends TestCase
|
|||
|
||||
public function testEmailSentToUserIfSettingEnabled()
|
||||
{
|
||||
Notification::fake();
|
||||
Mail::fake();
|
||||
|
||||
$user = User::factory()->create();
|
||||
$accessory = Accessory::factory()->checkedOutToUser($user)->create();
|
||||
|
@ -54,17 +56,14 @@ class AccessoryCheckinTest extends TestCase
|
|||
'',
|
||||
));
|
||||
|
||||
Notification::assertSentTo(
|
||||
[$user],
|
||||
function (CheckinAccessoryNotification $notification, $channels) {
|
||||
return in_array('mail', $channels);
|
||||
},
|
||||
);
|
||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||
});
|
||||
}
|
||||
|
||||
public function testEmailNotSentToUserIfSettingDisabled()
|
||||
{
|
||||
Notification::fake();
|
||||
Mail::fake();
|
||||
|
||||
$user = User::factory()->create();
|
||||
$accessory = Accessory::factory()->checkedOutToUser($user)->create();
|
||||
|
@ -78,11 +77,8 @@ class AccessoryCheckinTest extends TestCase
|
|||
'',
|
||||
));
|
||||
|
||||
Notification::assertNotSentTo(
|
||||
[$user],
|
||||
function (CheckinAccessoryNotification $notification, $channels) {
|
||||
return in_array('mail', $channels);
|
||||
},
|
||||
);
|
||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace Tests\Feature\Checkouts\Ui;
|
||||
|
||||
use App\Mail\CheckoutAccessoryMail;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckoutAccessoryNotification;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -156,7 +158,7 @@ class AccessoryCheckoutTest extends TestCase
|
|||
|
||||
public function testUserSentNotificationUponCheckout()
|
||||
{
|
||||
Notification::fake();
|
||||
Mail::fake();
|
||||
|
||||
$accessory = Accessory::factory()->requiringAcceptance()->create();
|
||||
$user = User::factory()->create();
|
||||
|
@ -168,7 +170,9 @@ class AccessoryCheckoutTest extends TestCase
|
|||
'checkout_to_type' => 'user',
|
||||
]);
|
||||
|
||||
Notification::assertSentTo($user, CheckoutAccessoryNotification::class);
|
||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||
});
|
||||
}
|
||||
|
||||
public function testActionLogCreatedUponCheckout()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Checkouts\Ui;
|
||||
|
||||
use App\Mail\CheckoutConsumableMail;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Component;
|
||||
|
@ -64,7 +65,7 @@ class ConsumableCheckoutTest extends TestCase
|
|||
'assigned_to' => $user->id,
|
||||
]);
|
||||
|
||||
Mail::assertSent(CheckoutConsumableNotification::class, function ($mail) use ($consumable, $user) {
|
||||
Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) {
|
||||
return $mail->hasTo($user) && $mail->consumables->contains($consumable);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Importing\Api;
|
||||
|
||||
use App\Mail\CheckoutAssetMail;
|
||||
use App\Models\Actionlog as ActionLog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\CustomField;
|
||||
|
@ -11,6 +12,7 @@ use App\Notifications\CheckoutAssetNotification;
|
|||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
|
@ -54,7 +56,7 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq
|
|||
#[Test]
|
||||
public function importAsset(): void
|
||||
{
|
||||
Notification::fake();
|
||||
Mail::fake();
|
||||
|
||||
$importFileBuilder = ImportFileBuilder::new();
|
||||
$row = $importFileBuilder->firstRow();
|
||||
|
@ -138,7 +140,7 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq
|
|||
//Notes is never read.
|
||||
// $this->assertEquals($row['notes'], $newAsset->notes);
|
||||
|
||||
Notification::assertSentTo($assignee, CheckoutAssetNotification::class);
|
||||
Mail::assertSent($assignee, CheckoutAssetMail::class);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
|
|
Loading…
Reference in a new issue