-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add ClientTest for WPush
- Add new test file ClientTest.php - Add test case for sending message using Client class with Authenticator and Message classes
- Loading branch information
Showing
1 changed file
with
39 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,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\WPush; | ||
|
||
use Guanguans\Notify\WPush\Authenticator; | ||
use Guanguans\Notify\WPush\Client; | ||
use Guanguans\Notify\WPush\Messages\Message; | ||
|
||
it('can send message', function (): void { | ||
$authenticator = new Authenticator('WPUSHXtvzuCujtOcL1cFkF1NC9aef'); | ||
$client = new Client($authenticator); | ||
$message = Message::make([ | ||
'title' => 'This is title.', | ||
'content' => 'This is content.', | ||
'channel' => 'wechat', | ||
// 'topic_code' => 'topic_code', | ||
]); | ||
|
||
expect($client) | ||
->mock([ | ||
create_response('{"code":0,"message":"success","data":"50285451654725632"}'), | ||
create_response('{"code":401,"message":"API Key错误","data":null}'), | ||
]) | ||
->assertCanSendMessage($message); | ||
})->group(__DIR__, __FILE__); |