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