Skip to content

Commit

Permalink
feat(AnPush): add ClientTest.php for sending message
Browse files Browse the repository at this point in the history
- Added ClientTest.php file for testing message sending functionality in AnPush
- Included test case for sending a message with mock responses
  • Loading branch information
guanguans committed May 10, 2024
1 parent 8a5e378 commit 486af99
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AnPush/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

## Related links

* [https://anpush.com/](https://anpush.com/)
* [https://anpush.com](https://anpush.com)
* [https://anpush.com/doc](https://anpush.com/doc)
39 changes: 39 additions & 0 deletions tests/AnPush/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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\AnPush;

use Guanguans\Notify\AnPush\Authenticator;
use Guanguans\Notify\AnPush\Client;
use Guanguans\Notify\AnPush\Messages\Message;

it('can send message', function (): void {
$authenticator = new Authenticator('FE3LGGYQZXRZ6A50BN66M42H0BY');
$client = new Client($authenticator);
$message = Message::make([
'title' => 'This is title.',
'content' => 'This is content.',
'channel' => '94412',
// 'to' => 'ov_1i8jk39d****',
]);

expect($client)
->mock([
create_response('{"msg":"success","code":200,"data":{"msgIds":[{"channelId":"94412","msgId":1715333937401}]}}'),
create_response('{"msg":"Token not found","code":10006}'),
])
->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);

0 comments on commit 486af99

Please sign in to comment.