Skip to content

Commit

Permalink
feat(tests): add ClientTest for WPush
Browse files Browse the repository at this point in the history
- Add new test file ClientTest.php
- Add test case for sending message using Client class with Authenticator and Message classes
  • Loading branch information
guanguans committed May 10, 2024
1 parent c462999 commit 9f0ec59
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/WPush/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\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__);

0 comments on commit 9f0ec59

Please sign in to comment.