Skip to content

Commit d8239a8

Browse files
author
tintnaingwin
committed
update smspoh test
1 parent 4213847 commit d8239a8

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Notification::route('smspoh', '5555555555')
9191

9292
`content()`: Set a content of the notification message. This parameter should be no longer than 918 char(6 message parts),
9393

94-
`test()`: Send a test message to specific mobile number or not. This parameter should be boolean(1 or 0).
94+
`test()`: Send a test message to specific mobile number or not. This parameter should be boolean and default value is `true`.
9595
## Changelog
9696

9797
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

src/Exceptions/CouldNotSendNotification.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class CouldNotSendNotification extends Exception
1010
/**
1111
* Thrown when content length is greater than 918 characters.
1212
*
13+
* @param $count
1314
* @return static
1415
*/
1516
public static function contentLengthLimitExceeded($count): self

src/SmspohApi.php

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

33
namespace NotificationChannels\Smspoh;
44

5+
use DomainException;
56
use GuzzleHttp\Client as HttpClient;
67
use GuzzleHttp\Exception\ClientException;
78
use GuzzleHttp\Exception\GuzzleException;
@@ -25,6 +26,11 @@ class SmspohApi
2526
*/
2627
protected $sender;
2728

29+
/**
30+
* @var string
31+
*/
32+
protected $token;
33+
2834
public function __construct($token = null, HttpClient $httpClient = null)
2935
{
3036
$this->token = $token;
@@ -63,14 +69,14 @@ public function send($message)
6369
'sender' => Arr::get($message, 'sender'),
6470
'to' => Arr::get($message, 'to'),
6571
'message' => Arr::get($message, 'message'),
66-
'test' => Arr::get($message, 'test', 0),
72+
'test' => Arr::get($message, 'test', false),
6773
],
6874
]);
6975

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

7278
if (isset($response['error'])) {
73-
throw new \DomainException($response['error'], $response['error_code']);
79+
throw new DomainException($response['error'], $response['error_code']);
7480
}
7581

7682
return $response;

src/SmspohChannel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SmspohChannel
1010
/**
1111
* The Smspoh client instance.
1212
*
13-
* @var \NotificationChannels\Smspoh\SmspohApi
13+
* @var SmspohApi
1414
*/
1515
protected $smspoh;
1616

@@ -37,10 +37,10 @@ public function __construct(SmspohApi $smspoh, $sender)
3737
* Send the given notification.
3838
*
3939
* @param mixed $notifiable
40-
* @param \Illuminate\Notifications\Notification $notification
40+
* @param Notification $notification
4141
*
4242
* @return mixed|\Psr\Http\Message\ResponseInterface|void
43-
* @throws \NotificationChannels\Smspoh\Exceptions\CouldNotSendNotification
43+
* @throws CouldNotSendNotification
4444
*/
4545
public function send($notifiable, Notification $notification)
4646
{
@@ -62,7 +62,7 @@ public function send($notifiable, Notification $notification)
6262
'sender' => $message->sender ?: $this->sender,
6363
'to' => $to,
6464
'message' => trim($message->content),
65-
'test' => $message->test ?: 0,
65+
'test' => $message->test ?: false,
6666
]);
6767
}
6868
}

src/SmspohMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SmspohMessage
2323
*
2424
* @var bool
2525
*/
26-
public $test;
26+
public $test = false;
2727

2828
/**
2929
* Create a new message instance.
@@ -68,7 +68,7 @@ public function sender($sender)
6868
* @param bool $test
6969
* @return $this
7070
*/
71-
public function test($test)
71+
public function test($test = true)
7272
{
7373
$this->test = $test;
7474

tests/SmspohChannelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function it_can_send_a_notification(): void
2626
'sender' => '5554443333',
2727
'to' => '5555555555',
2828
'message' => 'this is my message',
29-
'test' => 0,
29+
'test' => false,
3030
])->once();
3131

3232
$channel->send(new TestNotifiable(), new TestNotification());

tests/SmspohMessageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function it_can_set_the_from(): void
3333
/** @test */
3434
public function it_can_set_the_test(): void
3535
{
36-
$message = (new SmspohMessage())->test(1);
36+
$message = (new SmspohMessage())->test(true);
3737

38-
$this->assertEquals(1, $message->test);
38+
$this->assertTrue($message->test);
3939
}
4040
}

0 commit comments

Comments
 (0)