首页 > 解决方案 > 测试是否已发送按需 nexmo 通知

问题描述

我认为我应该能够做到这一点,使用类似的东西:

Notification::assertSentTo(new AnonymousNotifiable(), Notification::class, function($notification, $channels, $notifiable){
            return $notifiable->routes['mail'] == 'mail@yahoo.com';
        });

https://github.com/laravel/framework/pull/21379

但我不确定如何将它用于 nexmo 路线,我正在尝试这样的事情:

Notification::assertSentTo(new AnonymousNotifiable(), Notification::class, function($notification, $channels, $notifiable){
            return $notifiable->routes['nexmo'] == '12345';
        });

我收到“未发送预期的 [Illuminate\Support\Facades\Notification] 通知。无法断言 false 为真。”

有任何想法吗?

标签: laravel

解决方案


得到这个像这样工作:

Notification::assertSentTo(new AnonymousNotifiable(), SMS::class, function($notification, $channels, $notifiable) use ($toNumber){
            return $notifiable->routes['nexmo'] == $toNumber;
        });

推荐阅读