-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathClientTest.php
48 lines (38 loc) · 1.42 KB
/
ClientTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/** @noinspection StaticClosureCanBeUsedInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
/**
* Copyright (c) 2021-2025 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\XiZhi;
use Guanguans\Notify\XiZhi\Authenticator;
use Guanguans\Notify\XiZhi\Client;
use Guanguans\Notify\XiZhi\Messages\ChannelMessage;
use Guanguans\Notify\XiZhi\Messages\SingleMessage;
beforeEach(function (): void {
$authenticator = new Authenticator('XZf0db6d069509ec52afc1f3493b76e');
$this->client = (new Client($authenticator))->mock([
response('{"code":200,"msg":"推送成功"}'),
response('{"code":10000,"msg":"用户不存在"}'),
]);
});
it('can send single message', function (): void {
$singleMessage = SingleMessage::make([
'title' => 'This is title.',
'content' => 'This is content.',
]);
expect($this->client)->assertCanSendMessage($singleMessage);
})->group(__DIR__, __FILE__);
it('can send channel message', function (): void {
$channelMessage = ChannelMessage::make([
'title' => 'This is title.',
'content' => 'This is content.',
]);
expect($this->client)->assertCanSendMessage($channelMessage);
})->group(__DIR__, __FILE__);