Skip to content

Commit

Permalink
feat: laravel 9 support + fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
tintnaingwinn committed Feb 5, 2022
1 parent 7a8b45f commit 982ee95
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.phar
composer.lock
.DS_Stor
.phpunit.result.cache
coverage.clover
22 changes: 15 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

All notable changes to `smspoh` will be documented in this file

## 1.0.0 - 2019-12-25
## 1.3.0 - 2022-02-05

- initial release
## What's Changed

## 1.0.1 - 2020-02-05
- Laravel 9 support

- Laravel 7 support
## 1.2.0 - 2021-12-05

## What's Changed

- Add PHP 8 support
- Drop Laravel 5.*

## 1.1.0 - 2020-09-26

- Laravel 8 support

## 1.2.0 - 2021-12-05
## 1.0.1 - 2020-02-05

- Add PHP 8 support
- Drop Laravel 5.*
- Laravel 7 support

## 1.0.0 - 2019-12-25

- initial release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/smspoh.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/smspoh)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)

This package makes it easy to send notifications using [SmsPoh](https://smspoh.com/) with Laravel 6.x, 7.x and 8.x
This package makes it easy to send notifications using [SmsPoh](https://smspoh.com/) with Laravel 6.x, 7.x, 8.x and 9.x

## Contents

Expand Down
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "laravel-notification-channels/smspoh",
"description": "Smspoh Notifications channel for Laravel 6, 7 and 8.",
"description": "Smspoh Notifications channel for Laravel 6, 7, 8 and 9.",
"keywords": ["laravel", "notifications", "smspoh", "message", "sms", "myanmar", "MPT", "Telenor", "Ooredoo", "MyTel"],
"homepage": "https://github.com/laravel-notification-channels/smspoh",
"license": "MIT",
Expand All @@ -16,13 +16,13 @@
"php": "^7.2 || ^8.0",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.4 || ^7.0",
"illuminate/notifications": "^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0"
"illuminate/notifications": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^8.0|^9.0",
"orchestra/testbench": "^4.0|^5.0|^6.0"
"phpunit/phpunit": "^8.0 || ^9.0",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,9 +42,6 @@
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"laravel": {
"providers": [
"NotificationChannels\\Smspoh\\SmspohServiceProvider"
Expand Down
9 changes: 1 addition & 8 deletions src/SmspohApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace NotificationChannels\Smspoh;

use DomainException;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\GuzzleException;
Expand Down Expand Up @@ -73,13 +72,7 @@ public function send($message)
],
]);

$response = json_decode((string) $response->getBody(), true);

if (isset($response['error'])) {
throw new DomainException($response['error'], $response['error_code']);
}

return $response;
return json_decode((string) $response->getBody(), true);
} catch (ClientException $e) {
throw CouldNotSendNotification::smspohRespondedWithAnError($e);
} catch (GuzzleException $e) {
Expand Down
49 changes: 45 additions & 4 deletions tests/SmspohApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,66 @@

namespace NotificationChannels\Smspoh\Tests;

use GuzzleHttp\Client;
use NotificationChannels\Smspoh\Exceptions\CouldNotSendNotification;
use NotificationChannels\Smspoh\SmspohApi;

class SmspohApiTest extends TestCase
{
private $token = 'token';

/** @test */
public function it_has_config_with_default(): void
{
$token = 'token';
$endpoint = 'https://smspoh.com/api/v2/send';

config()->set('services.smspoh.token', $token);
config()->set('services.smspoh.token', $this->token);
config()->set('services.smspoh.endpoint', $endpoint);

$smspoh = $this->getExtendedSmspohApi($token);
$smspoh = $this->getExtendedSmspohApi($this->token);

$this->assertEquals($token, $smspoh->getToken());
$this->assertEquals($this->token, $smspoh->getToken());
$this->assertEquals($endpoint, $smspoh->getEndpoint());
}

/** @test */
public function it_can_check_smspoh_responded_with_error(): void
{
$this->withoutExceptionHandling();

$smspoh = new SmspohApi($this->token, new Client());

$this->expectException(CouldNotSendNotification::class);
$this->expectExceptionCode(401);

$smspoh->send([
'sender' => '5554443333',
'to' => '5555555555',
'message' => 'this is my message',
'test' => true,
]);
}


/** @test */
public function it_can_check_not_communicate_with_smspoh(): void
{
$this->withoutExceptionHandling();

config()->set('services.smspoh.endpoint', 'https://smspoh2.com/api/v2/send');

$smspoh = new SmspohApi($this->token, new Client());

$this->expectException(CouldNotSendNotification::class);

$smspoh->send([
'sender' => '5554443333',
'to' => '5555555555',
'message' => 'this is my message',
'test' => true,
]);
}

private function getExtendedSmspohApi($token)
{
return new class($token) extends SmspohApi {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use NotificationChannels\Smspoh\SmspohServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
abstract class TestCase extends Orchestra
{
use MockeryPHPUnitIntegration;

Expand Down

0 comments on commit 982ee95

Please sign in to comment.