-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
ClientTest.php
39 lines (32 loc) · 1.75 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
<?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\PushBullet;
use Guanguans\Notify\PushBullet\Authenticator;
use Guanguans\Notify\PushBullet\Client;
use Guanguans\Notify\PushBullet\Messages\Message;
it('can send message', function (): void {
$authenticator = new Authenticator('o.6UZlb92nYG8XIloqKdUecYVamaP3A');
$client = new Client($authenticator);
$message = Message::make([
'type' => 'link',
'title' => 'This is title.',
'body' => 'This is body.',
'url' => 'https://github.com/guanguans/notify',
]);
expect($client)
->mock([
response('{"active":true,"iden":"ujEkbcC7F0esjuPmSKdbKC","created":1709867052.256945,"modified":1709867052.256945,"type":"link","dismissed":false,"direction":"self","sender_iden":"ujEkbcC7F0e","sender_email":"[email protected]","sender_email_normalized":"[email protected]","sender_name":"姚明明","receiver_iden":"ujEkbcC7F0e","receiver_email":"[email protected]","receiver_email_normalized":"[email protected]","title":"This is title.","body":"This is body.","url":"https://github.com/guanguans/notify"}'),
response('{"error":{"code":"invalid_access_token","type":"invalid_request","message":"Access token is missing or invalid.","cat":"(=^・ω・^)y="},"error_code":"invalid_access_token"}', 401),
])
->assertCanSendMessage($message);
})->group(__DIR__, __FILE__);