Skip to content

Commit dceb8e3

Browse files
committed
attempt to fix tests
1 parent 123cdeb commit dceb8e3

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

tests/Feature/Checkins/Ui/AccessoryCheckinTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace Tests\Feature\Checkins\Ui;
44

55
use App\Events\CheckoutableCheckedIn;
6+
use App\Mail\CheckoutAccessoryMail;
67
use App\Models\Accessory;
78
use App\Models\User;
89
use App\Notifications\CheckinAccessoryNotification;
910
use Illuminate\Support\Facades\Event;
11+
use Illuminate\Support\Facades\Mail;
1012
use Illuminate\Support\Facades\Notification;
1113
use Tests\TestCase;
1214

@@ -40,7 +42,7 @@ public function testAccessoryCanBeCheckedIn()
4042

4143
public function testEmailSentToUserIfSettingEnabled()
4244
{
43-
Notification::fake();
45+
Mail::fake();
4446

4547
$user = User::factory()->create();
4648
$accessory = Accessory::factory()->checkedOutToUser($user)->create();
@@ -54,17 +56,14 @@ public function testEmailSentToUserIfSettingEnabled()
5456
'',
5557
));
5658

57-
Notification::assertSentTo(
58-
[$user],
59-
function (CheckinAccessoryNotification $notification, $channels) {
60-
return in_array('mail', $channels);
61-
},
62-
);
59+
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
60+
return $mail->hasTo($user) && $mail->contains($accessory);
61+
});
6362
}
6463

6564
public function testEmailNotSentToUserIfSettingDisabled()
6665
{
67-
Notification::fake();
66+
Mail::fake();
6867

6968
$user = User::factory()->create();
7069
$accessory = Accessory::factory()->checkedOutToUser($user)->create();
@@ -78,11 +77,8 @@ public function testEmailNotSentToUserIfSettingDisabled()
7877
'',
7978
));
8079

81-
Notification::assertNotSentTo(
82-
[$user],
83-
function (CheckinAccessoryNotification $notification, $channels) {
84-
return in_array('mail', $channels);
85-
},
86-
);
80+
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
81+
return $mail->hasTo($user) && $mail->contains($accessory);
82+
});
8783
}
8884
}

tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Tests\Feature\Checkouts\Ui;
44

5+
use App\Mail\CheckoutAccessoryMail;
56
use App\Models\Accessory;
67
use App\Models\Actionlog;
78
use App\Models\Asset;
89
use App\Models\Location;
910
use App\Models\User;
1011
use App\Notifications\CheckoutAccessoryNotification;
12+
use Illuminate\Support\Facades\Mail;
1113
use Illuminate\Support\Facades\Notification;
1214
use Tests\TestCase;
1315

@@ -156,7 +158,7 @@ public function testAccessoryCanBeCheckedOutToAssetWithQuantity()
156158

157159
public function testUserSentNotificationUponCheckout()
158160
{
159-
Notification::fake();
161+
Mail::fake();
160162

161163
$accessory = Accessory::factory()->requiringAcceptance()->create();
162164
$user = User::factory()->create();
@@ -168,7 +170,9 @@ public function testUserSentNotificationUponCheckout()
168170
'checkout_to_type' => 'user',
169171
]);
170172

171-
Notification::assertSentTo($user, CheckoutAccessoryNotification::class);
173+
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
174+
return $mail->hasTo($user) && $mail->contains($accessory);
175+
});
172176
}
173177

174178
public function testActionLogCreatedUponCheckout()

tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests\Feature\Checkouts\Ui;
44

5+
use App\Mail\CheckoutConsumableMail;
56
use App\Models\Actionlog;
67
use App\Models\Asset;
78
use App\Models\Component;
@@ -64,7 +65,7 @@ public function testUserSentNotificationUponCheckout()
6465
'assigned_to' => $user->id,
6566
]);
6667

67-
Mail::assertSent(CheckoutConsumableNotification::class, function ($mail) use ($consumable, $user) {
68+
Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) {
6869
return $mail->hasTo($user) && $mail->consumables->contains($consumable);
6970
});
7071
}

tests/Feature/Importing/Api/ImportAssetsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests\Feature\Importing\Api;
44

5+
use App\Mail\CheckoutAssetMail;
56
use App\Models\Actionlog as ActionLog;
67
use App\Models\Asset;
78
use App\Models\CustomField;
@@ -11,6 +12,7 @@
1112
use Carbon\Carbon;
1213
use Illuminate\Foundation\Testing\WithFaker;
1314
use Illuminate\Support\Arr;
15+
use Illuminate\Support\Facades\Mail;
1416
use Illuminate\Support\Facades\Notification;
1517
use Illuminate\Support\Str;
1618
use Illuminate\Testing\TestResponse;
@@ -54,7 +56,7 @@ public function userWithImportAssetsPermissionCanImportAssets(): void
5456
#[Test]
5557
public function importAsset(): void
5658
{
57-
Notification::fake();
59+
Mail::fake();
5860

5961
$importFileBuilder = ImportFileBuilder::new();
6062
$row = $importFileBuilder->firstRow();
@@ -138,7 +140,7 @@ public function importAsset(): void
138140
//Notes is never read.
139141
// $this->assertEquals($row['notes'], $newAsset->notes);
140142

141-
Notification::assertSentTo($assignee, CheckoutAssetNotification::class);
143+
Mail::assertSent($assignee, CheckoutAssetMail::class);
142144
}
143145

144146
#[Test]

0 commit comments

Comments
 (0)