5
5
use Illuminate \Contracts \Events \Dispatcher ;
6
6
use Illuminate \Notifications \Notification ;
7
7
use Mockery ;
8
+ use Mockery \Adapter \Phpunit \MockeryTestCase ;
8
9
use NotificationChannels \Twilio \TwilioCallMessage ;
9
10
use NotificationChannels \Twilio \TwilioChannel ;
10
11
use NotificationChannels \Twilio \TwilioConfig ;
11
12
use NotificationChannels \Twilio \TwilioSmsMessage ;
12
- use PHPUnit_Framework_TestCase ;
13
13
use NotificationChannels \Twilio \Twilio ;
14
- use Services_Twilio as TwilioService ;
15
- use Services_Twilio_Rest_Calls ;
16
- use Services_Twilio_Rest_Messages ;
14
+ use Twilio \ Rest \ Client as TwilioService ;
15
+ use Twilio \ Rest \ Api \ V2010 \ Account \ MessageList ;
16
+ use Twilio \ Rest \ Api \ V2010 \ Account \ CallList ;
17
17
18
- class IntegrationTest extends PHPUnit_Framework_TestCase
18
+ class IntegrationTest extends MockeryTestCase
19
19
{
20
20
/** @var TwilioService */
21
21
protected $ twilioService ;
@@ -31,9 +31,8 @@ public function setUp()
31
31
parent ::setUp ();
32
32
33
33
$ this ->twilioService = Mockery::mock (TwilioService::class);
34
- $ this ->twilioService ->account = new \stdClass ();
35
- $ this ->twilioService ->account ->messages = Mockery::mock (Services_Twilio_Rest_Messages::class);
36
- $ this ->twilioService ->account ->calls = Mockery::mock (Services_Twilio_Rest_Calls::class);
34
+ $ this ->twilioService ->messages = Mockery::mock (MessageList::class);
35
+ $ this ->twilioService ->calls = Mockery::mock (CallList::class);
37
36
38
37
$ this ->events = Mockery::mock (Dispatcher::class);
39
38
$ this ->notification = Mockery::mock (Notification::class);
@@ -51,7 +50,10 @@ public function it_can_send_a_sms_message()
51
50
$ twilio = new Twilio ($ this ->twilioService , $ config );
52
51
$ channel = new TwilioChannel ($ twilio , $ this ->events );
53
52
54
- $ this ->smsMessageWillBeSentToTwilioWith ('+31612345678 ' , '+22222222222 ' , 'Message text ' , null , []);
53
+ $ this ->smsMessageWillBeSentToTwilioWith ('+22222222222 ' , [
54
+ 'from ' => '+31612345678 ' ,
55
+ 'body ' => 'Message text '
56
+ ]);
55
57
56
58
$ channel ->send (new NotifiableWithAttribute (), $ this ->notification );
57
59
}
@@ -69,8 +71,10 @@ public function it_can_send_a_sms_message_using_service()
69
71
$ twilio = new Twilio ($ this ->twilioService , $ config );
70
72
$ channel = new TwilioChannel ($ twilio , $ this ->events );
71
73
72
- $ this ->smsMessageWillBeSentToTwilioWith ('+31612345678 ' , '+22222222222 ' , 'Message text ' , null , [
73
- 'MessagingServiceSid ' => '0123456789 '
74
+ $ this ->smsMessageWillBeSentToTwilioWith ('+22222222222 ' , [
75
+ 'from ' => '+31612345678 ' ,
76
+ 'body ' => 'Message text ' ,
77
+ 'messagingServiceSid ' => '0123456789 '
74
78
]);
75
79
76
80
$ channel ->send (new NotifiableWithAttribute (), $ this ->notification );
@@ -89,7 +93,10 @@ public function it_can_send_a_sms_message_using_alphanumeric_sender()
89
93
$ twilio = new Twilio ($ this ->twilioService , $ config );
90
94
$ channel = new TwilioChannel ($ twilio , $ this ->events );
91
95
92
- $ this ->smsMessageWillBeSentToTwilioWith ('TwilioTest ' , '+33333333333 ' , 'Message text ' , null , []);
96
+ $ this ->smsMessageWillBeSentToTwilioWith ('+33333333333 ' , [
97
+ 'from ' => 'TwilioTest ' ,
98
+ 'body ' => 'Message text '
99
+ ]);
93
100
94
101
$ channel ->send (new NotifiableWithAlphanumericSender (), $ this ->notification );
95
102
}
@@ -106,22 +113,24 @@ public function it_can_make_a_call()
106
113
$ twilio = new Twilio ($ this ->twilioService , $ config );
107
114
$ channel = new TwilioChannel ($ twilio , $ this ->events );
108
115
109
- $ this ->callWillBeSentToTwilioWith ('+31612345678 ' , '+22222222222 ' , 'http://example.com ' );
116
+ $ this ->callWillBeSentToTwilioWith ('+22222222222 ' , '+31612345678 ' , [
117
+ 'url ' => 'http://example.com '
118
+ ]);
110
119
111
120
$ channel ->send (new NotifiableWithAttribute (), $ this ->notification );
112
121
}
113
122
114
123
protected function smsMessageWillBeSentToTwilioWith (...$ args )
115
124
{
116
- $ this ->twilioService ->account -> messages ->shouldReceive ('sendMessage ' )
125
+ $ this ->twilioService ->messages ->shouldReceive ('create ' )
117
126
->atLeast ()->once ()
118
127
->with (...$ args )
119
128
->andReturn (true );
120
129
}
121
130
122
131
protected function callWillBeSentToTwilioWith (...$ args )
123
132
{
124
- $ this ->twilioService ->account -> calls ->shouldReceive ('create ' )
133
+ $ this ->twilioService ->calls ->shouldReceive ('create ' )
125
134
->atLeast ()->once ()
126
135
->with (...$ args )
127
136
->andReturn (true );
0 commit comments