-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathClientTest.php
52 lines (45 loc) · 1.69 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
<?php
/** @noinspection AnonymousFunctionStaticInspection */
/** @noinspection NullPointerExceptionInspection */
/** @noinspection PhpPossiblePolymorphicInvocationInspection */
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection StaticClosureCanBeUsedInspection */
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\Bark;
use Guanguans\Notify\Bark\Authenticator;
use Guanguans\Notify\Bark\Client;
use Guanguans\Notify\Bark\Messages\Message;
it('can send message', function (): void {
$authenticator = new Authenticator('yetwhxBm7wCBSUTjeqh');
$client = new Client($authenticator);
$message = Message::make([
'title' => 'This is title.',
'body' => 'This is body.',
'level' => 'active',
'badge' => 3,
'autoCopy' => 1,
'copy' => 'This is copy.',
'sound' => 'bell',
'icon' => 'https://avatars0.githubusercontent.com/u/25671453?s=200&v=4',
'group' => 'This is group.',
'isArchive' => 1,
'url' => 'https://github.com/guanguans/notify',
]);
expect($client)
->mock([
response('{"code":200,"message":"success","timestamp":1708331409}'),
response(
'{"code":400,"message":"failed to get device token: failed to get [yetwhxBm7wCBSUTjeqh] device token from database","timestamp":1708331590}',
400,
),
])
->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);