Skip to content

Commit 1b0490a

Browse files
committed
Merge remote-tracking branch 'origin/4.x' into onlime-rebrand
2 parents a18719e + cf2e7fa commit 1b0490a

16 files changed

+244
-49
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
/.gitignore export-ignore
88
/.travis.yml export-ignore
99
/phpunit.xml.dist export-ignore
10-
/.scrutinizer.yml export-ignore
11-
/.styleci.yml export-ignore
1210
/.editorconfig export-ignore
1311
/tests export-ignore

.github/workflows/ci.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6+
phplint:
7+
runs-on: ubuntu-latest
8+
9+
name: PHP Linting (Pint)
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: "laravel-pint"
16+
uses: aglipanci/laravel-pint-action@latest
17+
with:
18+
preset: laravel
19+
verboseMode: true
20+
testMode: true
21+
configPath: "pint.json"
22+
pintVersion: 1.18.2
23+
onlyDirty: true
24+
625
test:
726
runs-on: ubuntu-latest
827
strategy:
@@ -16,7 +35,7 @@ jobs:
1635
- laravel: 11.*
1736
testbench: 9.*
1837

19-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
38+
name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
2039

2140
steps:
2241
- name: Checkout

.scrutinizer.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to `laravel-notification-channels/twilio` will be documented
55
## 4.0.0
66

77
- Rebranded abandoned [`laravel-notification-channels/twilio`](https://github.com/laravel-notification-channels/twilio) to [`onlime/laravel-twilio`](https://github.com/onlime/laravel-twilio)
8+
- Added PHP Linting (Pint) to CI workflow
9+
- Additional tests to achieve 100% code coverage by @pascalbaljet
810
- Update PhpUnit to 10.5 and fixed all tests.
911
- Bump `twilio/sdk` to 8.3
1012
- Improved types and use constructor property promotion everywhere.

README.md

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

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/onlime/laravel-twilio.svg?style=flat-square)](https://packagist.org/packages/onlime/laravel-twilio)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5-
[![Build Status](https://github.com/onlime/laravel-notification-channels-twilio/actions/workflows/ci.yml/badge.svg)](https://github.com/onlime/laravel-notification-channels-twilio/actions/workflows/ci.yml)
6-
[![Quality Score](https://img.shields.io/scrutinizer/g/onlime/laravel-twilio.svg?style=flat-square)](https://scrutinizer-ci.com/g/onlime/laravel-twilio)
7-
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/onlime/laravel-twilio/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/onlime/laravel-twilio/?branch=master)
8-
[![Total Downloads](https://img.shields.io/packagist/dt/onlime/laravel-twilio.svg?style=flat-square)](https://packagist.org/packages/onlime/laravel-twilio)
5+
[![Build Status](https://github.com/onlime/laravel-twilio/actions/workflows/ci.yml/badge.svg)](https://github.com/onlime/laravel-twilio/actions/workflows/ci.yml)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/twilio.svg?style=flat-square)](https://packagist.org/packages/onlime/laravel-twilio)
97

108
This package makes it easy to send [Twilio notifications](https://documentation.twilio.com/docs) with Laravel 11.x
119

@@ -57,7 +55,7 @@ Run `php artisan vendor:publish --provider="NotificationChannels\Twilio\TwilioPr
5755
#### Suppressing specific errors or all errors
5856

5957
Publish the config using the above command, and edit the `ignored_error_codes` array. You can get the list of
60-
exception codes from [the documentation](https://www.twilio.com/docs/api/errors).
58+
exception codes from [the documentation](https://www.twilio.com/docs/api/errors).
6159

6260
If you want to suppress all errors, you can set the option to `['*']`. The errors will not be logged but notification
6361
failed events will still be emitted.
@@ -75,8 +73,8 @@ We have dropped support for PHP < 8.2 and the minimum Laravel version is now 11.
7573

7674
## Upgrading from 2.x to 3.x
7775

78-
If you're upgrading from version `2.x`, you'll need to make sure that your set environment variables match those above
79-
in the config section. None of the environment variable names have changed, but if you used different keys in your
76+
If you're upgrading from version `2.x`, you'll need to make sure that your set environment variables match those above
77+
in the config section. None of the environment variable names have changed, but if you used different keys in your
8078
`services.php` config then you'll need to update them to match the above, or publish the config file and change the
8179
`env` key.
8280

src/Exceptions/CouldNotSendNotification.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,4 @@ public static function invalidReceiver(): self
3030
method or a phone_number attribute to your notifiable.'
3131
);
3232
}
33-
34-
public static function missingAlphaNumericSender(): self
35-
{
36-
return new static(
37-
'Notification was not sent. Missing `alphanumeric_sender` in config'
38-
);
39-
}
4033
}

src/TwilioProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public function register(): void
6767
public function provides(): array
6868
{
6969
return [
70+
TwilioChannel::class,
7071
TwilioConfig::class,
7172
TwilioService::class,
72-
TwilioChannel::class,
7373
];
7474
}
7575
}

tests/Integration/TwilioProviderTest.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
use NotificationChannels\Twilio\Exceptions\InvalidConfigException;
88
use NotificationChannels\Twilio\Tests\IntegrationTestCase;
99
use NotificationChannels\Twilio\TwilioChannel;
10+
use NotificationChannels\Twilio\TwilioConfig;
11+
use NotificationChannels\Twilio\TwilioProvider;
12+
use Twilio\Rest\Client;
1013

1114
class TwilioProviderTest extends IntegrationTestCase
1215
{
13-
public function testThatApplicationCannotCreateChannelWithoutConfig()
16+
/** @test */
17+
public function it_cannot_create_the_application_without_config()
1418
{
1519
$this->expectException(InvalidConfigException::class);
1620

1721
$this->app->get(TwilioChannel::class);
1822
}
1923

20-
public function testThatApplicationCannotCreateChannelWithoutSid()
24+
/** @test */
25+
public function it_cannot_create_the_application_without_sid()
2126
{
2227
$this->app['config']->set('twilio-notification-channel.username', 'test');
2328
$this->app['config']->set('twilio-notification-channel.username', 'password');
@@ -26,12 +31,32 @@ public function testThatApplicationCannotCreateChannelWithoutSid()
2631
$this->app->get(TwilioChannel::class);
2732
}
2833

29-
public function testThatApplicationCreatesChannelWithConfig()
34+
/** @test */
35+
public function it_can_create_the_application_with_sid()
3036
{
3137
$this->app['config']->set('twilio-notification-channel.username', 'test');
3238
$this->app['config']->set('twilio-notification-channel.password', 'password');
3339
$this->app['config']->set('twilio-notification-channel.account_sid', '1234');
3440

3541
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
3642
}
43+
44+
/** @test */
45+
public function it_can_create_the_application_with_token_auth()
46+
{
47+
$this->app['config']->set('twilio-notification-channel.auth_token', 'token');
48+
$this->app['config']->set('twilio-notification-channel.account_sid', '1234');
49+
50+
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
51+
}
52+
53+
/** @test */
54+
public function it_provides_three_classes()
55+
{
56+
$provides = (new TwilioProvider($this->app))->provides();
57+
58+
$this->assertTrue(in_array(TwilioChannel::class, $provides));
59+
$this->assertTrue(in_array(TwilioConfig::class, $provides));
60+
$this->assertTrue(in_array(Client::class, $provides));
61+
}
3762
}

tests/Unit/IntegrationTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace NotificationChannels\Twilio\Tests\Unit;
44

55
use Illuminate\Contracts\Events\Dispatcher;
6+
use Illuminate\Notifications\Events\NotificationFailed;
67
use Illuminate\Notifications\Notification;
78
use Mockery;
89
use Mockery\Adapter\Phpunit\MockeryTestCase;
10+
use NotificationChannels\Twilio\Exceptions\CouldNotSendNotification;
911
use NotificationChannels\Twilio\Twilio;
1012
use NotificationChannels\Twilio\TwilioCallMessage;
1113
use NotificationChannels\Twilio\TwilioChannel;
@@ -28,7 +30,7 @@ class IntegrationTest extends MockeryTestCase
2830
/** @var Dispatcher */
2931
protected $events;
3032

31-
public function setUp(): void
33+
protected function setUp(): void
3234
{
3335
parent::setUp();
3436

@@ -144,6 +146,27 @@ public function it_can_make_a_call()
144146
$channel->send(new NotifiableWithAttribute, $this->notification);
145147
}
146148

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+
147170
protected function smsMessageWillBeSentToTwilioWith(...$args)
148171
{
149172
$this->twilioService->messages->shouldReceive('create')

0 commit comments

Comments
 (0)