-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(SimplePush): add test case for sending message
- Added test case for sending a message using SimplePush Client - Includes test for sending message with specific details and attachments - Mocked responses for successful and failed message sending
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** @noinspection StaticClosureCanBeUsedInspection */ | ||
/** @noinspection PhpUnhandledExceptionInspection */ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2024 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/notify | ||
*/ | ||
|
||
namespace Guanguans\NotifyTests\SimplePush; | ||
|
||
use Guanguans\Notify\SimplePush\Authenticator; | ||
use Guanguans\Notify\SimplePush\Client; | ||
use Guanguans\Notify\SimplePush\Messages\Message; | ||
|
||
it('can send message', function (): void { | ||
$authenticator = new Authenticator('tw8xxx'); | ||
$client = new Client($authenticator); | ||
$message = Message::make([ | ||
'msg' => 'This is message.', | ||
'title' => 'This is title.', | ||
'event' => 'This is event.', | ||
'actions' => [ | ||
[ | ||
'name' => 'notify', | ||
'url' => 'https://github.com/guanguans/notify', | ||
], | ||
[ | ||
'name' => 'laravel-exception-notify', | ||
'url' => 'https://github.com/guanguans/laravel-exception-notify', | ||
], | ||
], | ||
'attachments' => [ | ||
'https://raw.githubusercontent.com/guanguans/notify/main/tests/fixtures/image.png', | ||
], | ||
]); | ||
|
||
expect($client) | ||
->mock([ | ||
create_response('{"status":"OK"}'), | ||
create_response('', 406), | ||
]) | ||
->assertCanSendMessage($message); | ||
})->group(__DIR__, __FILE__); |