/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Notifications/NotificationDatabaseChannelTest.php
102 строки
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\Notifications\Channels\DatabaseChannel; use Illuminate\Notifications\Messages\DatabaseMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Carbon; use Mockery; use PHPUnit\Framework\TestCase; class NotificationDatabaseChannelTest extends TestCase { public function testDatabaseChannelCreatesDatabaseRecordWithProperData() { $notification = new NotificationDatabaseChannelTestNotification; $notification->id = 1; $notifiable = Mockery::mock(); $notifiable->expects('routeNotificationFor->create')->with([ 'id' => 1, 'type' => get_class($notification), 'data' => ['invoice_id' => 1], 'read_at' => null, ]); $channel = new DatabaseChannel; $channel->send($notifiable, $notification); } public function testCorrectPayloadIsSentToDatabase() { $notification = new NotificationDatabaseChannelTestNotification; $notification->id = 1; $notifiable = Mockery::mock(); $notifiable->expects('routeNotificationFor->create')->with([ 'id' => 1, 'type' => get_class($notification), 'data' => ['invoice_id' => 1], 'read_at' => null, 'something' => 'else', ]); $channel = new ExtendedDatabaseChannel; $channel->send($notifiable, $notification); } public function testCustomizeTypeIsSentToDatabase() { $notification = new NotificationDatabaseChannelCustomizeTypeTestNotification; $notification->id = 1; $notifiable = Mockery::mock(); $notifiable->expects('routeNotificationFor->create')->with([ 'id' => 1, 'type' => 'MONTHLY', 'data' => ['invoice_id' => 1], 'read_at' => Carbon::now()->toDateTimeString(), 'something' => 'else', ]); $channel = new ExtendedDatabaseChannel; $channel->send($notifiable, $notification); } } class NotificationDatabaseChannelTestNotification extends Notification { public function toDatabase($notifiable) { return new DatabaseMessage(['invoice_id' => 1]); } } class NotificationDatabaseChannelCustomizeTypeTestNotification extends Notification { public function toDatabase($notifiable) { return new DatabaseMessage(['invoice_id' => 1]); } public function databaseType() { return 'MONTHLY'; } public function initialDatabaseReadAtValue() { return Carbon::now(); } } class ExtendedDatabaseChannel extends DatabaseChannel { protected function buildPayload($notifiable, Notification $notification) { return array_merge(parent::buildPayload($notifiable, $notification), [ 'something' => 'else', ]); } }