X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/dabe79a438f22612e7d68c8d1de7817505b59b93..refs/pull/2227/head:/tests/TestEmailTest.php diff --git a/tests/TestEmailTest.php b/tests/TestEmailTest.php index c06311d84..76ff322ff 100644 --- a/tests/TestEmailTest.php +++ b/tests/TestEmailTest.php @@ -1,6 +1,7 @@ mock(Dispatcher::class); + $this->app[Dispatcher::class] = $mockDispatcher; + + $exception = new \Exception('A random error occurred when testing an email'); + $mockDispatcher->shouldReceive('send')->andThrow($exception); + + $admin = $this->getAdmin(); + $sendReq = $this->actingAs($admin)->post('/settings/maintenance/send-test-email'); + $sendReq->assertRedirect('/settings/maintenance#image-cleanup'); + $this->assertSessionHas('error'); + + $message = session()->get('error'); + $this->assertStringContainsString('Error thrown when sending a test email:', $message); + $this->assertStringContainsString('A random error occurred when testing an email', $message); + } + public function test_send_test_email_requires_settings_manage_permission() { Notification::fake();