laravel - 测试是否已发送按需 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 为真。”
有任何想法吗?
解决方案
得到这个像这样工作:
Notification::assertSentTo(new AnonymousNotifiable(), SMS::class, function($notification, $channels, $notifiable) use ($toNumber){
return $notifiable->routes['nexmo'] == $toNumber;
});
推荐阅读
- reactjs - Can't add data to firebase firestore Error: React Native: Possible unhandled promise rejection (id: 0) TypeError: Network request failed
- bash - 使用 sed 提取几个键值对
- sql - 如何在 Oracle 中找到两个大小范围之间缺失的大小范围?
- python - 在 Matplotlib 3.1.2 中使用 qt5agg 后端,get_backend() 会改变行为
- excel - 基于多个条件将多行提取到有限模板中
- reactjs - 如何使用 Kitten UI 进行单元测试
- javascript - 将 json 数据转换为相应的文件类型
- javascript - 创建循环而不是一遍又一遍地复制/粘贴代码
- nim-lang - Nim 支持类型推断吗?
- python - msys: pip install cffi 由于未定义的引用而失败