Skip to content

Commit 0df7062

Browse files
committed
Fixing Twilio and TwilioChannel tests
1 parent b68f87c commit 0df7062

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/TwilioConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace NotificationChannels\Twilio;
44

5-
readonly class TwilioConfig
5+
class TwilioConfig
66
{
77
public function __construct(
8-
private array $config
8+
private readonly array $config
99
) {}
1010

1111
public function enabled(): bool

tests/Unit/TwilioChannelTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function setUp(): void
3131
parent::setUp();
3232

3333
$this->twilio = Mockery::mock(Twilio::class);
34+
$this->twilio->config = new TwilioConfig([]);
3435
$this->dispatcher = Mockery::mock(Dispatcher::class);
3536

3637
$this->channel = new TwilioChannel($this->twilio, $this->dispatcher);

tests/Unit/TwilioTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function it_can_send_a_sms_message_to_twilio()
6767
->once()
6868
->andReturn(null);
6969

70+
$this->config->shouldReceive('isShortenUrlsEnabled')
71+
->once()
72+
->andReturn(false);
73+
7074
$this->config->shouldReceive('getServiceSid')
7175
->once()
7276
->andReturn(null);
@@ -104,6 +108,10 @@ public function it_can_send_a_mms_message_to_twilio()
104108
->once()
105109
->andReturn('+1234567890');
106110

111+
$this->config->shouldReceive('isShortenUrlsEnabled')
112+
->once()
113+
->andReturn(false);
114+
107115
$this->config->shouldReceive('getServiceSid')
108116
->once()
109117
->andReturn(null);
@@ -141,6 +149,10 @@ public function it_can_send_a_sms_message_to_twilio_with_alphanumeric_sender()
141149

142150
$this->config->shouldNotReceive('getFrom');
143151

152+
$this->config->shouldReceive('isShortenUrlsEnabled')
153+
->once()
154+
->andReturn(false);
155+
144156
$this->config->shouldReceive('getServiceSid')
145157
->once()
146158
->andReturn(null);
@@ -169,6 +181,10 @@ public function it_can_send_a_sms_message_to_twilio_with_messaging_service()
169181
->once()
170182
->andReturn('+1234567890');
171183

184+
$this->config->shouldReceive('isShortenUrlsEnabled')
185+
->once()
186+
->andReturn(false);
187+
172188
$this->config->shouldReceive('getServiceSid')
173189
->once()
174190
->andReturn('service_sid');
@@ -201,6 +217,10 @@ public function it_can_send_a_call_to_twilio()
201217
$message->fallbackUrl('http://example.com');
202218
$message->fallbackMethod('PUT');
203219

220+
$this->config->shouldReceive('getDebugTo')
221+
->once()
222+
->andReturn('+1111111111');
223+
204224
$this->twilioService->calls->shouldReceive('create')
205225
->atLeast()->once()
206226
->with('+1111111111', '+2222222222', [
@@ -233,6 +253,10 @@ public function it_will_throw_an_exception_in_case_of_a_missing_from_number()
233253
->once()
234254
->andReturn(null);
235255

256+
$this->config->shouldReceive('isShortenUrlsEnabled')
257+
->once()
258+
->andReturn(false);
259+
236260
$this->config->shouldReceive('getServiceSid')
237261
->once()
238262
->andReturn(null);
@@ -270,6 +294,10 @@ public function it_should_use_universal_to()
270294
->once()
271295
->andReturn($debugTo);
272296

297+
$this->config->shouldReceive('isShortenUrlsEnabled')
298+
->once()
299+
->andReturn(false);
300+
273301
$this->config->shouldReceive('getServiceSid')
274302
->once()
275303
->andReturn(null);

0 commit comments

Comments
 (0)