-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
ClientTest.php
87 lines (71 loc) · 2.81 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/** @noinspection StaticClosureCanBeUsedInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
/**
* Copyright (c) 2021-2024 guanguans<ityaozm@gmail.com>
*
* 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\Chanify;
use Guanguans\Notify\Chanify\Authenticator;
use Guanguans\Notify\Chanify\Client;
use Guanguans\Notify\Chanify\Messages\AudioMessage;
use Guanguans\Notify\Chanify\Messages\FileMessage;
use Guanguans\Notify\Chanify\Messages\ImageMessage;
use Guanguans\Notify\Chanify\Messages\LinkMessage;
use Guanguans\Notify\Chanify\Messages\TextMessage;
beforeEach(function (): void {
$authenticator = new Authenticator('CICwhbIGEiJBQVdIWlVKS1JORVY0UlVETFZYVVpRTlNLTlVZVlZPT1JFIgIIAQ.orHlBVavQPrY-ZP3eqQKDgjyTtNdZPdNYV6lpAx8');
$this->client = (new Client($authenticator))->mock([
response('{"request-uid":"03fe6123-2098-4af8-a210-658010a69d9c"}'),
response('{"res":400,"msg":"bad request"}', 400),
]);
});
it('can send text message', function (): void {
$textMessage = TextMessage::make([
'title' => 'This is title.',
'text' => 'This is text.',
'copy' => 'This is copy.',
'autocopy' => 1,
'sound' => 'bell',
'priority' => 5,
'interruptionlevel' => 'active',
'actions' => [
'ActionName1|http://<action host>/<action1>',
'ActionName2|http://<action host>/<action2>',
],
'timeline' => [
'code' => '<timeline code>',
'timestamp' => 1620000000000,
'items' => [
'key1' => 'value1',
'key2' => 'value2',
],
],
]);
expect($this->client)->assertCanSendMessage($textMessage);
})->group(__DIR__, __FILE__);
it('can send audio message', function (): void {
$audioMessage = AudioMessage::make()->audio('This is audio path.');
expect($this->client)->assertCanSendMessage($audioMessage);
})->group(__DIR__, __FILE__);
it('can send file message', function (): void {
$fileMessage = FileMessage::make()->file('This is file path.');
expect($this->client)->assertCanSendMessage($fileMessage);
})->group(__DIR__, __FILE__);
it('can send image message', function (): void {
$imageMessage = ImageMessage::make()->image('This is image path.');
expect($this->client)->assertCanSendMessage($imageMessage);
})->group(__DIR__, __FILE__);
it('can send link message', function (): void {
$linkMessage = LinkMessage::make([
'link' => 'https://github.com/guanguans/notify',
'sound' => 1,
'priority' => 10,
]);
expect($this->client)->assertCanSendMessage($linkMessage);
})->group(__DIR__, __FILE__);