Skip to content

Commit 596f197

Browse files
authored
Merge pull request #7 from seven-io/master
Support Laravel 11 and more
2 parents 4cf8724 + 2c8513e commit 596f197

File tree

8 files changed

+56
-97
lines changed

8 files changed

+56
-97
lines changed

.github/workflows/php.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ on:
88

99
jobs:
1010
build:
11-
12-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: [ 8.3, 8.2 ]
17+
laravel: [ '10.*', '11.*' ]
18+
stability: [prefer-lowest, prefer-stable]
19+
include:
20+
- laravel: 11.*
21+
testbench: 9.*
22+
- laravel: 10.*
23+
testbench: 8.*
1324

1425
steps:
1526
- uses: actions/checkout@v2

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=7.2",
16-
"guzzlehttp/guzzle": "^6.5 || ^7.0",
17-
"illuminate/notifications": "~5.5 || ~6.0 || ~7.0 || ^8.0 || ^9.0 || ^10.0",
18-
"illuminate/support": "~5.5 || ~6.0 || ~7.0 || ^8.0 || ^9.0 || ^10.0"
15+
"php": "^8.2",
16+
"guzzlehttp/guzzle": "^7.1",
17+
"illuminate/notifications": "^10.0 || ^11.0",
18+
"illuminate/support": "^10.0 || ^11.0"
1919
},
2020
"require-dev": {
21-
"mockery/mockery": "^1.3",
22-
"phpunit/phpunit": "^8.0 || ^9.0"
21+
"mockery/mockery": "^1.5",
22+
"phpunit/phpunit": "^10.5|^11.0"
2323
},
2424
"autoload": {
2525
"psr-4": {

phpunit.xml.dist

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="SMS77 Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
22-
<logging>
23-
<log type="junit" target="build/report.junit.xml"/>
24-
<log type="coverage-html" target="build/coverage"/>
25-
<log type="coverage-text" target="build/coverage.txt"/>
26-
<log type="coverage-clover" target="build/logs/clover.xml"/>
27-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<coverage>
4+
<report>
5+
<clover outputFile="build/logs/clover.xml"/>
6+
<html outputDirectory="build/coverage"/>
7+
<text outputFile="build/coverage.txt"/>
8+
</report>
9+
</coverage>
10+
<testsuites>
11+
<testsuite name="SMS77 Test Suite">
12+
<directory>tests</directory>
13+
</testsuite>
14+
</testsuites>
15+
<logging>
16+
<junit outputFile="build/report.junit.xml"/>
17+
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
2823
</phpunit>

src/SMS77.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,26 @@
55
use Exception;
66
use GuzzleHttp\Client as HttpClient;
77
use GuzzleHTtp\Exception\ClientException;
8+
use GuzzleHttp\Exception\GuzzleException;
89
use NotificationChannels\SMS77\Exceptions\CouldNotSendNotification;
910

1011
class SMS77
1112
{
1213
/**
1314
* @var string SMS77 API URL.
1415
*/
15-
protected string $apiUrl = 'https://gateway.sms77.io/api/';
16+
protected string $apiUrl = 'https://gateway.seven.io/api/';
1617

17-
/**
18-
* @var HttpClient HTTP Client.
19-
*/
20-
protected $http;
21-
22-
/**
23-
* @var null|string SMS77 API Key.
24-
*/
25-
protected $apiKey;
2618

2719
/**
2820
* @param string $apiKey
2921
* @param HttpClient $http
3022
*/
31-
public function __construct(string $apiKey = null, HttpClient $http = null)
32-
{
33-
$this->apiKey = $apiKey;
34-
$this->http = $http;
35-
}
23+
public function __construct(
24+
protected string|null $apiKey = null,
25+
protected HttpClient|null $http = null
26+
)
27+
{}
3628

3729
/**
3830
* Get API key.
@@ -49,8 +41,7 @@ public function getApiKey(): string
4941
*
5042
* @param string $apiKey
5143
*/
52-
public function setApiKey(string $apiKey)
53-
{
44+
public function setApiKey(string $apiKey): void {
5445
$this->apiKey = $apiKey;
5546
}
5647

@@ -72,7 +63,6 @@ protected function httpClient(): HttpClient
7263
* 'to' => '',
7364
* 'text' => '',
7465
* 'from' => '',
75-
* 'debug' => '',
7666
* 'delay' => '',
7767
* 'no_reload' => '',
7868
* 'unicode' => '',
@@ -97,6 +87,10 @@ public function sendMessage(array $params)
9787
return $this->sendRequest('sms', $params);
9888
}
9989

90+
/**
91+
* @throws GuzzleException
92+
* @throws CouldNotSendNotification
93+
*/
10094
public function sendRequest(string $endpoint, array $params)
10195
{
10296
if (empty($this->apiKey)) {

src/SMS77Channel.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@
77

88
class SMS77Channel
99
{
10-
/**
11-
* @var SMS77
12-
*/
13-
protected $sms77;
14-
1510
/**
1611
* @param SMS77 $sms77
1712
*/
18-
public function __construct(SMS77 $sms77)
19-
{
20-
$this->sms77 = $sms77;
21-
}
13+
public function __construct(protected SMS77 $sms77)
14+
{}
2215

2316
/**
2417
* Send the given notification.

src/SMS77Message.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class SMS77Message
66
{
7-
protected $payload = [];
7+
protected array $payload = [];
88

99
/**
1010
* @param string $message
@@ -114,16 +114,6 @@ public function noReload(): self
114114
return $this;
115115
}
116116

117-
/**
118-
* Activate debug mode.
119-
*/
120-
public function debug(): self
121-
{
122-
$this->payload['debug'] = 1;
123-
124-
return $this;
125-
}
126-
127117
/**
128118
* Set encoding to unicode.
129119
*/

tests/SMS77ChannelTest.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,6 @@ public function testSmsIsSentWithCustomFrom()
8787
self::assertSame($this->expectedResponse, $actualResponse);
8888
}
8989

90-
public function testSmsSentWithDebugging()
91-
{
92-
$notification = new TestSmsNotificationWithDebiggung;
93-
$notifiable = new TestNotifiable;
94-
95-
$this->sms77->shouldReceive('sendMessage')->once()
96-
->with([
97-
'json' => 1,
98-
'debug' => 1,
99-
'from' => '5554443333',
100-
'to' => '5555555555',
101-
'text' => 'This is my message.',
102-
])
103-
->andReturns(new Response(200, [], json_encode($this->expectedResponse)));
104-
105-
$actualResponse = $this->channel->send($notifiable, $notification);
106-
107-
self::assertSame($this->expectedResponse, $actualResponse);
108-
}
109-
11090
public function testSmsSendWithAllMessageOptions()
11191
{
11292
$notification = new TestSmsNotificationWithAllMessageOptions;
@@ -118,7 +98,6 @@ public function testSmsSendWithAllMessageOptions()
11898
'to' => '123456789',
11999
'text' => 'This is my message.',
120100
'delay' => '000000',
121-
'debug' => 1,
122101
'no_reload' => 1,
123102
'unicode' => 1,
124103
'flash' => 1,
@@ -174,7 +153,7 @@ class TestSmsNotificationWithDebiggung extends Notification
174153
{
175154
public function toSms77($notifiable)
176155
{
177-
return (new SMS77Message('This is my message.'))->from('5554443333')->debug();
156+
return (new SMS77Message('This is my message.'))->from('5554443333');
178157
}
179158
}
180159

@@ -189,7 +168,6 @@ public function toSms77($notifiable)
189168
->to('123456789')
190169
->from('987654321')
191170
->delay('00000000')
192-
->debug()
193171
->noReload()
194172
->unicode()
195173
->flash()

tests/SMS77MessageTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function testApiJsonResponseIsEnabledByDefault()
3535
public function testMessageCanReturnPayloadAsArray()
3636
{
3737
$message = (new SMS77Message('This is my message.'))
38-
->debug()
3938
->from('SMS')
4039
->to('123456789')
4140
->flash();
@@ -46,7 +45,6 @@ public function testMessageCanReturnPayloadAsArray()
4645
'to' => '123456789',
4746
'text' => 'This is my message.',
4847
'flash' => 1,
49-
'debug' => 1,
5048
];
5149

5250
$this->assertEquals($expected, $message->toArray());

0 commit comments

Comments
 (0)