/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Notifications/NotificationSendQueuedNotificationTest.php
90 строк
3 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Notifications; use Illuminate\Contracts\Database\ModelIdentifier; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\AnonymousNotifiable; use Illuminate\Notifications\ChannelManager; use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notification; use Illuminate\Notifications\SendQueuedNotifications; use Illuminate\Queue\Attributes\FailOnTimeout; use Illuminate\Support\Collection; use Mockery; use PHPUnit\Framework\TestCase; class NotificationSendQueuedNotificationTest extends TestCase { public function testNotificationsCanBeSent() { $notification = new TestNotification; $job = new SendQueuedNotifications('notifiables', $notification); $manager = Mockery::mock(ChannelManager::class); $manager->expects('sendNow')->withArgs(function ($notifiables, $notification, $channels) { return $notifiables instanceof Collection && $notifiables->toArray() === ['notifiables'] && $notification instanceof TestNotification && $channels === null; }); $job->handle($manager); } public function testSerializationOfNotifiableModel() { $identifier = new ModelIdentifier(NotifiableUser::class, [null], [], null); $serializedIdentifier = serialize($identifier); $job = new SendQueuedNotifications(new NotifiableUser, new TestNotification); $serialized = serialize($job); $this->assertStringContainsString($serializedIdentifier, $serialized); } public function testSerializationOfNormalNotifiable() { $notifiable = new AnonymousNotifiable; $serializedNotifiable = serialize($notifiable); $job = new SendQueuedNotifications($notifiable, new TestNotification); $serialized = serialize($job); $this->assertStringContainsString($serializedNotifiable, $serialized); } public function testNotificationCanSetMaxExceptions() { $notifiable = new NotifiableUser; $notification = new class { public $maxExceptions = 23; }; $job = new SendQueuedNotifications($notifiable, $notification); $this->assertEquals(23, $job->maxExceptions); } public function testNotificationRespectsFailOnTimeoutAttribute() { $job = new SendQueuedNotifications(new NotifiableUser, new FailOnTimeoutNotification); $this->assertTrue($job->failOnTimeout); } } class NotifiableUser extends Model { use Notifiable; public $table = 'users'; public $timestamps = false; } class TestNotification extends Notification { } #[FailOnTimeout] class FailOnTimeoutNotification extends Notification { }