From 4842eabf186e803199b6335483dfee7ec836f134 Mon Sep 17 00:00:00 2001 From: atymic Date: Mon, 9 Mar 2020 09:48:46 +1100 Subject: [PATCH] feat: laravel 7 support + fix name (#35) --- .gitignore | 1 + README.md | 4 ++-- composer.json | 14 +++++++------- src/WebhookChannel.php | 4 ++-- tests/ChannelTest.php | 13 ++++++------- tests/MessageTest.php | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 3f0a634..d07f69a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build composer.phar composer.lock +.phpunit.result.cache diff --git a/README.md b/README.md index 81b5202..0b48cba 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Webhook notifications channel for Laravel 5.5+ and 6.0 +# Webhook notifications channel for Laravel [![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/webhook.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/webhook) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) @@ -9,7 +9,7 @@ [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/webhook/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/webhook/?branch=master) [![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/webhook.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/webhook) -This package makes it easy to send webhooks using the Laravel notification system. +This package makes it easy to send webhooks using the Laravel notification system. Supports 5.5+. 6.x and 7.x. ## Contents diff --git a/composer.json b/composer.json index 7522274..69ada50 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ } ], "require": { - "php": ">=7.0", + "php": ">=7.2.5", "guzzlehttp/guzzle": "~6.0", - "illuminate/notifications": "~5.5 || ~6.0", - "illuminate/support": "~5.5 || ~6.0" + "illuminate/notifications": "~5.5 || ~6.0 || ~7.0", + "illuminate/support": "~5.5 || ~6.0 || ~7.0" }, "require-dev": { - "mockery/mockery": "^0.9.5", - "phpunit/phpunit": "~7.0 || ~8.0", - "orchestra/testbench": "^3.5.0 || ^4.0", - "orchestra/database": "^3.5.0 || ^4.0" + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^8.0", + "orchestra/testbench": "^3.8.0 || ^4.0 || ^5.0", + "orchestra/database": "^3.8.0 || ^4.0 | ^5.0" }, "autoload": { "psr-4": { diff --git a/src/WebhookChannel.php b/src/WebhookChannel.php index a058310..359c031 100644 --- a/src/WebhookChannel.php +++ b/src/WebhookChannel.php @@ -3,8 +3,8 @@ namespace NotificationChannels\Webhook; use GuzzleHttp\Client; -use Illuminate\Support\Arr; use Illuminate\Notifications\Notification; +use Illuminate\Support\Arr; use NotificationChannels\Webhook\Exceptions\CouldNotSendNotification; class WebhookChannel @@ -32,7 +32,7 @@ public function __construct(Client $client) */ public function send($notifiable, Notification $notification) { - if (! $url = $notifiable->routeNotificationFor('Webhook')) { + if (! $url = $notifiable->routeNotificationFor('webhook')) { return; } diff --git a/tests/ChannelTest.php b/tests/ChannelTest.php index 51b19b2..6e57427 100644 --- a/tests/ChannelTest.php +++ b/tests/ChannelTest.php @@ -2,14 +2,14 @@ namespace NotificationChannels\Webhook\Test; -use Mockery; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Response; -use Orchestra\Testbench\TestCase; use Illuminate\Notifications\Notification; +use Mockery; +use NotificationChannels\Webhook\Exceptions\CouldNotSendNotification; use NotificationChannels\Webhook\WebhookChannel; use NotificationChannels\Webhook\WebhookMessage; -use NotificationChannels\Webhook\Exceptions\CouldNotSendNotification; +use Orchestra\Testbench\TestCase; class ChannelTest extends TestCase { @@ -89,16 +89,15 @@ public function it_can_send_a_notification_with_query_string() } /** - * @expectedException NotificationChannels\Webhook\Exceptions\CouldNotSendNotification * @test */ public function it_throws_an_exception_when_it_could_not_send_the_notification() { $response = new Response(500); - $this->expectExceptionObject( - new CouldNotSendNotification($response, 'Webhook responded with an error: ``', 500) - ); + $this->expectException(CouldNotSendNotification::class); + $this->expectExceptionMessage('Webhook responded with an error: ``'); + $this->expectExceptionCode(500); $client = Mockery::mock(Client::class); $client->shouldReceive('post') diff --git a/tests/MessageTest.php b/tests/MessageTest.php index dd70ebc..3e5a800 100644 --- a/tests/MessageTest.php +++ b/tests/MessageTest.php @@ -3,15 +3,15 @@ namespace NotificationChannels\Webhook\Test; use Illuminate\Support\Arr; -use Orchestra\Testbench\TestCase; use NotificationChannels\Webhook\WebhookMessage; +use Orchestra\Testbench\TestCase; class MessageTest extends TestCase { /** @var \NotificationChannels\Webhook\WebhookMessage */ protected $message; - public function setUp() + public function setUp(): void { parent::setUp(); $this->message = new WebhookMessage();