Skip to content

Commit 8a329e7

Browse files
Add missing tests for the notification fake (#39337)
1 parent 9362a29 commit 8a329e7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/Support/SupportTestingNotificationFakeTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Exception;
66
use Illuminate\Contracts\Translation\HasLocalePreference;
77
use Illuminate\Foundation\Auth\User;
8+
use Illuminate\Notifications\AnonymousNotifiable;
89
use Illuminate\Notifications\Notification;
910
use Illuminate\Support\Collection;
1011
use Illuminate\Support\Testing\Fakes\NotificationFake;
@@ -61,6 +62,22 @@ public function testAssertSentToClosure()
6162
});
6263
}
6364

65+
public function testAssertSentOnDemand()
66+
{
67+
$this->fake->send(new AnonymousNotifiable, new NotificationStub);
68+
69+
$this->fake->assertSentOnDemand(NotificationStub::class);
70+
}
71+
72+
public function testAssertSentOnDemandClosure()
73+
{
74+
$this->fake->send(new AnonymousNotifiable, new NotificationStub);
75+
76+
$this->fake->assertSentOnDemand(NotificationStub::class, function (NotificationStub $notification) {
77+
return true;
78+
});
79+
}
80+
6481
public function testAssertNotSentTo()
6582
{
6683
$this->fake->assertNotSentTo($this->user, NotificationStub::class);
@@ -134,6 +151,32 @@ public function testAssertTimesSent()
134151
$this->fake->assertTimesSent(3, NotificationStub::class);
135152
}
136153

154+
public function testAssertSentToTimes()
155+
{
156+
$this->fake->assertSentToTimes($this->user, NotificationStub::class, 0);
157+
158+
$this->fake->send($this->user, new NotificationStub);
159+
160+
$this->fake->send($this->user, new NotificationStub);
161+
162+
$this->fake->send($this->user, new NotificationStub);
163+
164+
$this->fake->assertSentToTimes($this->user, NotificationStub::class, 3);
165+
}
166+
167+
public function testAssertSentOnDemandTimes()
168+
{
169+
$this->fake->assertSentOnDemandTimes(NotificationStub::class, 0);
170+
171+
$this->fake->send(new AnonymousNotifiable, new NotificationStub);
172+
173+
$this->fake->send(new AnonymousNotifiable, new NotificationStub);
174+
175+
$this->fake->send(new AnonymousNotifiable, new NotificationStub);
176+
177+
$this->fake->assertSentOnDemandTimes(NotificationStub::class, 3);
178+
}
179+
137180
public function testAssertSentToWhenNotifiableHasPreferredLocale()
138181
{
139182
$user = new LocalizedUserStub;

0 commit comments

Comments
 (0)