-
-
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.
feat(AnPush): add ClientTest.php for sending message
- Added ClientTest.php file for testing message sending functionality in AnPush - Included test case for sending a message with mock responses
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
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
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,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__); |