Skip to content

Commit

Permalink
Merge pull request #158 from laravel-notification-channels/laravel-12
Browse files Browse the repository at this point in the history
Laravel 12 Support
  • Loading branch information
onlime authored Mar 3, 2025
2 parents c5a78ce + 1476025 commit b9601ea
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[ci.yml]
indent_size = 2
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on: [push, pull_request]
on:
- push
- pull_request

jobs:
phplint:
Expand All @@ -12,14 +14,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: "laravel-pint"
- name: laravel-pint
uses: aglipanci/laravel-pint-action@latest
with:
preset: laravel
verboseMode: true
testMode: true
configPath: "pint.json"
pintVersion: 1.18.2
configPath: pint.json
pintVersion: 1.21.0
onlyDirty: true

test:
Expand All @@ -28,12 +30,14 @@ jobs:
max-parallel: 15
fail-fast: false
matrix:
php: [8.3, 8.2]
laravel: [11.*]
php: [8.4, 8.3, 8.2]
laravel: ['11.*', '12.*']
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 12.*
testbench: 10.*

name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

All notable changes to `laravel-notification-channels/twilio` will be documented in this file.

## 4.0.0
## [4.1.0](https://github.com/laravel-notification-channels/twilio/releases/tag/4.1.0) (2025-03-03)

- Added Laravel 12 support #155 #157

## [4.0.0](https://github.com/laravel-notification-channels/twilio/releases/tag/4.0.0) (2024-11-26)

- Added PHP Linting (Pint) to CI workflow
- Additional tests to achieve 100% code coverage by @pascalbaljet
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@
"require": {
"php": "^8.2",
"twilio/sdk": "^7.16 || ^8.3",
"illuminate/notifications": "^11.0",
"illuminate/support": "^11.0",
"illuminate/events": "^11.0",
"illuminate/queue": "^11.0"
"illuminate/notifications": "^11.0 || ^12.0",
"illuminate/support": "^11.0 || ^12.0",
"illuminate/events": "^11.0 || ^12.0",
"illuminate/queue": "^11.0 || ^12.0"
},
"require-dev": {
"laravel/pint": "^1.18",
"laravel/pint": "^1.21",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.5"
"orchestra/testbench": "^9.0 || ^10.0",
"phpunit/phpunit": "^10.5 || ^11.5.10"
},
"autoload": {
"psr-4": {
Expand Down
11 changes: 6 additions & 5 deletions tests/Integration/TwilioProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioConfig;
use NotificationChannels\Twilio\TwilioProvider;
use PHPUnit\Framework\Attributes\Test;
use Twilio\Rest\Client;

class TwilioProviderTest extends IntegrationTestCase
{
/** @test */
#[Test]
public function it_cannot_create_the_application_without_config()
{
$this->expectException(InvalidConfigException::class);

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

/** @test */
#[Test]
public function it_cannot_create_the_application_without_sid()
{
$this->app['config']->set('twilio-notification-channel.username', 'test');
Expand All @@ -31,7 +32,7 @@ public function it_cannot_create_the_application_without_sid()
$this->app->get(TwilioChannel::class);
}

/** @test */
#[Test]
public function it_can_create_the_application_with_sid()
{
$this->app['config']->set('twilio-notification-channel.username', 'test');
Expand All @@ -41,7 +42,7 @@ public function it_can_create_the_application_with_sid()
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
}

/** @test */
#[Test]
public function it_can_create_the_application_with_token_auth()
{
$this->app['config']->set('twilio-notification-channel.auth_token', 'token');
Expand All @@ -50,7 +51,7 @@ public function it_can_create_the_application_with_token_auth()
$this->assertInstanceOf(TwilioChannel::class, $this->app->get(TwilioChannel::class));
}

/** @test */
#[Test]
public function it_provides_three_classes()
{
$provides = (new TwilioProvider($this->app))->provides();
Expand Down
13 changes: 7 additions & 6 deletions tests/Unit/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioConfig;
use NotificationChannels\Twilio\TwilioSmsMessage;
use PHPUnit\Framework\Attributes\Test;
use Twilio\Rest\Api\V2010\Account\CallInstance;
use Twilio\Rest\Api\V2010\Account\CallList;
use Twilio\Rest\Api\V2010\Account\MessageInstance;
Expand Down Expand Up @@ -42,7 +43,7 @@ protected function setUp(): void
$this->notification = Mockery::mock(Notification::class);
}

/** @test */
#[Test]
public function it_can_send_a_sms_message()
{
$message = TwilioSmsMessage::create('Message text');
Expand All @@ -62,7 +63,7 @@ public function it_can_send_a_sms_message()
$channel->send(new NotifiableWithAttribute, $this->notification);
}

/** @test */
#[Test]
public function it_can_send_a_sms_message_using_service()
{
$message = TwilioSmsMessage::create('Message text');
Expand All @@ -84,7 +85,7 @@ public function it_can_send_a_sms_message_using_service()
$channel->send(new NotifiableWithAttribute, $this->notification);
}

/** @test */
#[Test]
public function it_can_send_a_sms_message_using_url_shortener()
{
$message = TwilioSmsMessage::create('Message text');
Expand All @@ -106,7 +107,7 @@ public function it_can_send_a_sms_message_using_url_shortener()
$channel->send(new NotifiableWithAttribute, $this->notification);
}

/** @test */
#[Test]
public function it_can_send_a_sms_message_using_alphanumeric_sender()
{
$message = TwilioSmsMessage::create('Message text');
Expand All @@ -127,7 +128,7 @@ public function it_can_send_a_sms_message_using_alphanumeric_sender()
$channel->send(new NotifiableWithAlphanumericSender, $this->notification);
}

/** @test */
#[Test]
public function it_can_make_a_call()
{
$message = TwilioCallMessage::create('http://example.com');
Expand All @@ -146,7 +147,7 @@ public function it_can_make_a_call()
$channel->send(new NotifiableWithAttribute, $this->notification);
}

/** @test */
#[Test]
public function it_cant_make_a_call_when_the_from_config_is_missing()
{
$message = TwilioCallMessage::create('http://example.com');
Expand Down
9 changes: 5 additions & 4 deletions tests/Unit/TwilioCallMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NotificationChannels\Twilio\Tests\Unit;

use NotificationChannels\Twilio\TwilioCallMessage;
use PHPUnit\Framework\Attributes\Test;

class TwilioCallMessageTest extends TwilioMessageTestCase
{
Expand All @@ -16,31 +17,31 @@ protected function setUp(): void
$this->message = new TwilioCallMessage;
}

/** @test */
#[Test]
public function it_can_accept_a_message_when_constructing_a_message()
{
$message = new TwilioCallMessage('http://example.com');

$this->assertEquals('http://example.com', $message->content);
}

/** @test */
#[Test]
public function it_provides_a_create_method()
{
$message = TwilioCallMessage::create('http://example.com');

$this->assertEquals('http://example.com', $message->content);
}

/** @test */
#[Test]
public function it_can_set_the_url()
{
$this->message->url('http://example.com');

$this->assertEquals('http://example.com', $this->message->content);
}

/** @test */
#[Test]
public function it_can_set_optional_parameters()
{
$message = TwilioCallMessage::create('myMessage');
Expand Down
23 changes: 12 additions & 11 deletions tests/Unit/TwilioChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Twilio\TwilioConfig;
use NotificationChannels\Twilio\TwilioSmsMessage;
use PHPUnit\Framework\Attributes\Test;
use Twilio\Exceptions\RestException;

class TwilioChannelTest extends MockeryTestCase
Expand All @@ -37,7 +38,7 @@ protected function setUp(): void
$this->channel = new TwilioChannel($this->twilio, $this->dispatcher);
}

/** @test */
#[Test]
public function it_will_not_send_a_message_if_not_enabled()
{
$notifiable = new Notifiable;
Expand All @@ -54,7 +55,7 @@ public function it_will_not_send_a_message_if_not_enabled()
$this->assertNull($result);
}

/** @test */
#[Test]
public function it_will_not_send_a_message_without_known_receiver()
{
$notifiable = new Notifiable;
Expand All @@ -75,7 +76,7 @@ public function it_will_not_send_a_message_without_known_receiver()
$this->assertNull($result);
}

/** @test */
#[Test]
public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_the_notifiable()
{
$notifiable = new NotifiableWithMethod;
Expand All @@ -91,7 +92,7 @@ public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_the_notifiable_if_it_uses_the_twilio_channel_explicitly()
{
$notifiable = new NotifiableWithTwilioChannel;
Expand All @@ -107,7 +108,7 @@ public function it_will_send_a_sms_message_to_the_result_of_the_route_method_of_
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_make_a_call_to_the_phone_number_attribute_of_the_notifiable()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -123,7 +124,7 @@ public function it_will_make_a_call_to_the_phone_number_attribute_of_the_notifia
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_convert_a_string_to_a_sms_message()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -138,7 +139,7 @@ public function it_will_convert_a_string_to_a_sms_message()
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_fire_an_event_in_case_of_an_invalid_message()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -160,7 +161,7 @@ public function it_will_fire_an_event_in_case_of_an_invalid_message()
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_ignore_specific_error_codes()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -184,7 +185,7 @@ public function it_will_ignore_specific_error_codes()
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_rethrow_non_ignored_error_codes()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -210,7 +211,7 @@ public function it_will_rethrow_non_ignored_error_codes()
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_ignore_all_error_codes()
{
$notifiable = new NotifiableWithAttribute;
Expand All @@ -232,7 +233,7 @@ public function it_will_ignore_all_error_codes()
$this->channel->send($notifiable, $notification);
}

/** @test */
#[Test]
public function it_will_send_using_alphanumeric_if_notifiable_can_receive()
{
$notifiable = new NotifiableWithAlphanumericSender;
Expand Down
Loading

0 comments on commit b9601ea

Please sign in to comment.