3
3
namespace NotificationChannels \Twilio \Tests \Unit ;
4
4
5
5
use Illuminate \Contracts \Events \Dispatcher ;
6
+ use Illuminate \Notifications \Events \NotificationFailed ;
6
7
use Illuminate \Notifications \Notification ;
7
8
use Mockery ;
8
9
use Mockery \Adapter \Phpunit \MockeryTestCase ;
10
+ use NotificationChannels \Twilio \Exceptions \CouldNotSendNotification ;
9
11
use NotificationChannels \Twilio \Twilio ;
10
12
use NotificationChannels \Twilio \TwilioCallMessage ;
11
13
use NotificationChannels \Twilio \TwilioChannel ;
@@ -28,7 +30,7 @@ class IntegrationTest extends MockeryTestCase
28
30
/** @var Dispatcher */
29
31
protected $ events ;
30
32
31
- public function setUp (): void
33
+ protected function setUp (): void
32
34
{
33
35
parent ::setUp ();
34
36
@@ -144,6 +146,27 @@ public function it_can_make_a_call()
144
146
$ channel ->send (new NotifiableWithAttribute , $ this ->notification );
145
147
}
146
148
149
+ /** @test */
150
+ public function it_cant_make_a_call_when_the_from_config_is_missing ()
151
+ {
152
+ $ message = TwilioCallMessage::create ('http://example.com ' );
153
+ $ this ->notification ->shouldReceive ('toTwilio ' )->andReturn ($ message );
154
+
155
+ $ config = new TwilioConfig ([]);
156
+ $ twilio = new Twilio ($ this ->twilioService , $ config );
157
+ $ channel = new TwilioChannel ($ twilio , $ this ->events );
158
+
159
+ $ this ->twilioService ->calls ->shouldNotReceive ('create ' );
160
+
161
+ $ this ->events ->shouldReceive ('dispatch ' )
162
+ ->atLeast ()->once ()
163
+ ->with (Mockery::type (NotificationFailed::class));
164
+
165
+ $ this ->expectException (CouldNotSendNotification::class);
166
+
167
+ $ channel ->send (new NotifiableWithAttribute , $ this ->notification );
168
+ }
169
+
147
170
protected function smsMessageWillBeSentToTwilioWith (...$ args )
148
171
{
149
172
$ this ->twilioService ->messages ->shouldReceive ('create ' )
0 commit comments