-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathClientTest.php
69 lines (62 loc) · 2.39 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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\QQ;
use Guanguans\Notify\QQ\Authenticator;
use Guanguans\Notify\QQ\Client;
use Guanguans\Notify\QQ\Messages\Message;
it('can send message', function (): void {
$authenticator = new Authenticator(
'102001750',
'eghXYBXQH0QXBByb8Zj4VeRGterQG',
);
$client = new Client($authenticator);
$message = Message::make([
'channel_id' => '4316959',
'content' => 'This is content.',
'embed' => [],
'ark' => [
'template_id' => 'This is template id.',
'kv' => [
[
'key' => 'This is key.',
'value' => 'This is value.',
'obj' => [
[
'obj_kv' => [
[
'key' => 'This is obj key.',
'value' => 'This is obj value.',
],
],
],
],
],
],
],
'message_reference' => [],
'image' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
'file_image' => 'tests/fixtures/image.png',
'msg_id' => 'This is msg id.',
// 'event_id' => 'This is event id.',
'markdown' => [],
]);
expect($client)
->mock([
response('{"id":"08efdfa1b3e1d4d6e246109fbe8702383048e4d0ccae06","channel_id":"4316959","guild_id":"5099581822453968879","content":"This is content.","timestamp":"2024-02-19T18:07:32+08:00","tts":false,"mention_everyone":false,"author":{"id":"7938900097687957410","username":"","avatar":"","bot":true},"pinned":false,"type":0,"flags":0,"seq_in_channel":"48"}'),
response(
'{"message":"Token错误","code":11243,"err_code":40012002,"trace_id":"b363de10b4c8893a382b8b9d6d07c615"}',
401,
),
])
->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);