Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
想要使用PHPUnit在laravel中对松弛通知进行单元测试吗_Laravel_Notifications_Phpunit_Slack - Fatal编程技术网

想要使用PHPUnit在laravel中对松弛通知进行单元测试吗

想要使用PHPUnit在laravel中对松弛通知进行单元测试吗,laravel,notifications,phpunit,slack,Laravel,Notifications,Phpunit,Slack,请帮助我编写单元测试存根,以确定是否正在发送松弛通知。在一个批处理的执行过程中,如果发生错误,我将在空闲通道中发送错误。在测试中,您应该使用MockApplicationServices特性。它的工作原理与 用途是: $this->expectsNotification($notifiable, $notification); // eg. $this->expectsNotification($user, UpperLimitExceeded::class); 还有$this

请帮助我编写单元测试存根,以确定是否正在发送松弛通知。在一个批处理的执行过程中,如果发生错误,我将在空闲通道中发送错误。

在测试中,您应该使用MockApplicationServices特性。它的工作原理与

用途是:

$this->expectsNotification($notifiable, $notification);

// eg.
$this->expectsNotification($user, UpperLimitExceeded::class);

还有$this->withoutNotifications()可以跳过遇到的任何通知。

谢谢您的回复!但是,当我的测试存根调用方法时,我仍然得到一个错误:$this->notify(new\App\Notifications\TestNotification($out,$slackChannelName));错误如下:1)Tests\Unit\ApplicationControllerTest::testBatch BadMethodCallException:Method Mockery\u 0\u App\u Http\u Controllers\u ApplicationControllerGetKey不存在。出现1个故障:1)Tests\Unit\ApplicationControllerTest::testBatch未发送以下预期通知:[App\Http\Controllers\TestNotification]下面是我的源代码:$this->expectsNotification('test-slack',\App\Http\Controllers\TestNotification::class);]