Skip to content

Commit

Permalink
test(SimplePush): add test case for sending message
Browse files Browse the repository at this point in the history
- 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
guanguans committed Mar 20, 2024
1 parent 858edfc commit 967e2c4
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/SimplePush/ClientTest.php
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__);

0 comments on commit 967e2c4

Please sign in to comment.