-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
ClientTest.php
58 lines (51 loc) · 2.13 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
<?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\Ntfy;
use Guanguans\Notify\Ntfy\Client;
use Guanguans\Notify\Ntfy\Messages\Message;
it('can send message', function (): void {
$client = new Client;
$message = Message::make([
'topic' => 'guanguans',
'message' => 'This is message.',
'title' => 'This is title.',
'tags' => ['tag1', 'tag2'],
'priority' => 1,
'actions' => [],
'click' => 'https://www.guanguans.cn',
'attach' => 'https://avatars.githubusercontent.com/u/22309277?v=4',
'markdown' => true,
'icon' => 'https://avatars0.githubusercontent.com/u/25671453?s=200&v=4',
'filename' => 'avatar.png',
// 'delay' => '30min, 9am',
'email' => '[email protected]',
// 'call' => '+8613948484984',
'cache' => 'no',
'firebase' => 'no',
])->addAction([
'action' => 'view',
'label' => 'Open portal',
'url' => 'https://home.nest.com/',
'clear' => true,
]);
expect($client)
->mock([
response('{"id":"ChjDFVOPqaBK","time":1708335367,"expires":1708378567,"event":"message","topic":"guanguans","title":"This is title.","message":"This is message.","priority":1,"tags":["tag1","tag2"],"click":"https://example.com","icon":"https://www.guanguans.cn","attachment":{"name":"file.jpg","url":"https://www.guanguans.cn"}}'),
response(
'{"code":40035,"http":400,"error":"invalid request: anonymous phone calls are not allowed","link":"https://ntfy.sh/docs/publish/#phone-calls"}',
400,
),
response('{"code":40003,"http":400,"error":"delayed e-mail notifications are not supported"}', 400),
])
->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);