/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Notifications/NotificationRoutesNotificationsTest.php
74 строки
2 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Notifications; use Illuminate\Container\Container; use Illuminate\Contracts\Notifications\Dispatcher; use Illuminate\Notifications\RoutesNotifications; use Illuminate\Support\Facades\Notification; use InvalidArgumentException; use Mockery; use PHPUnit\Framework\TestCase; use stdClass; class NotificationRoutesNotificationsTest extends TestCase { protected function tearDown(): void { Container::setInstance(null); } public function testNotificationCanBeDispatched() { $container = new Container; $factory = Mockery::mock(Dispatcher::class); $container->instance(Dispatcher::class, $factory); $notifiable = new RoutesNotificationsTestInstance; $instance = new stdClass; $factory->expects('send')->with($notifiable, $instance); Container::setInstance($container); $notifiable->notify($instance); } public function testNotificationCanBeSentNow() { $container = new Container; $factory = Mockery::mock(Dispatcher::class); $container->instance(Dispatcher::class, $factory); $notifiable = new RoutesNotificationsTestInstance; $instance = new stdClass; $factory->expects('sendNow')->with($notifiable, $instance, null); Container::setInstance($container); $notifiable->notifyNow($instance); } public function testNotificationOptionRouting() { $instance = new RoutesNotificationsTestInstance; $this->assertSame('bar', $instance->routeNotificationFor('foo')); $this->assertSame('taylor@laravel.com', $instance->routeNotificationFor('mail')); } public function testOnDemandNotificationsCannotUseDatabaseChannel() { $this->expectExceptionObject( new InvalidArgumentException('The database channel does not support on-demand notifications.') ); Notification::route('database', 'foo'); } } class RoutesNotificationsTestInstance { use RoutesNotifications; protected $email = 'taylor@laravel.com'; public function routeNotificationForFoo() { return 'bar'; } }