-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathClientTest.php
57 lines (47 loc) · 1.59 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
<?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\Zulip;
use Guanguans\Notify\Zulip\Authenticator;
use Guanguans\Notify\Zulip\Client;
use Guanguans\Notify\Zulip\Messages\Message;
beforeEach(function (): void {
$authenticator = new Authenticator(
'mh4JvrIQzzkcBobWYLiFEOvI25t4Q',
);
$this->client = (new Client($authenticator))
->baseUri('https://xxx.zulipchat.com/')
->mock([
response('{"result":"success","msg":"","id":1740849}'),
response('{"result":"error","msg":"Malformed API key","code":"UNAUTHORIZED"}', 401),
]);
});
it('can send direct message', function (): void {
$message = Message::make([
'type' => 'direct',
'to' => '[email protected]',
'content' => 'This is content.',
]);
expect($this->client)->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);
it('can send stream message', function (): void {
$message = Message::make([
'type' => 'stream',
'to' => 'general',
'content' => 'This is content.',
'topic' => 'bug',
'queue_id' => '1593114627:0',
'local_id' => '100.01',
]);
expect($this->client)->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);