|
| 1 | +<?php |
| 2 | + |
| 3 | +/** @noinspection AnonymousFunctionStaticInspection */ |
| 4 | +/** @noinspection NullPointerExceptionInspection */ |
| 5 | +/** @noinspection PhpPossiblePolymorphicInvocationInspection */ |
| 6 | +/** @noinspection PhpUnhandledExceptionInspection */ |
| 7 | +/** @noinspection StaticClosureCanBeUsedInspection */ |
| 8 | + |
| 9 | +declare(strict_types=1); |
| 10 | + |
| 11 | +/** |
| 12 | + * Copyright (c) 2021-2025 guanguans<[email protected]> |
| 13 | + * |
| 14 | + * For the full copyright and license information, please view |
| 15 | + * the LICENSE file that was distributed with this source code. |
| 16 | + * |
| 17 | + * @see https://github.com/guanguans/notify |
| 18 | + */ |
| 19 | + |
| 20 | +namespace Guanguans\NotifyTests\ZohoCliq; |
| 21 | + |
| 22 | +use Guanguans\Notify\ZohoCliq\Authenticator; |
| 23 | +use Guanguans\Notify\ZohoCliq\Client; |
| 24 | +use Guanguans\Notify\ZohoCliq\Messages\Message; |
| 25 | + |
| 26 | +it('can send message', function (): void { |
| 27 | + // $token = Authenticator::generateToken('client-id', 'client-secret'); |
| 28 | + $authenticator = new Authenticator('company-id', 'your-channel', 'use $token'); |
| 29 | + $client = new Client($authenticator); |
| 30 | + $message = Message::make([ |
| 31 | + 'text' => 'This is a test message from ZohoCliq integration.', |
| 32 | + ]); |
| 33 | + |
| 34 | + expect($client) |
| 35 | + ->mock([ |
| 36 | + response(faker()->text()), |
| 37 | + ]) |
| 38 | + ->assertCanSendMessage($message); |
| 39 | +})->group(__DIR__, __FILE__); |
| 40 | + |
| 41 | +it('can send message with bot customization', function (): void { |
| 42 | + // $token = Authenticator::generateToken('client-id', 'client-secret'); |
| 43 | + $authenticator = new Authenticator('company-id', 'your-channel', 'use $token'); |
| 44 | + $client = new Client($authenticator); |
| 45 | + $message = Message::make([ |
| 46 | + 'text' => 'Hello from custom bot!', |
| 47 | + 'bot' => [ |
| 48 | + 'name' => 'Custom Bot', |
| 49 | + 'image' => 'https://example.com/bot-icon.png', |
| 50 | + ], |
| 51 | + ]); |
| 52 | + |
| 53 | + expect($client) |
| 54 | + ->mock([ |
| 55 | + response(faker()->text()), |
| 56 | + ]) |
| 57 | + ->assertCanSendMessage($message); |
| 58 | +})->group(__DIR__, __FILE__); |
| 59 | + |
| 60 | +it('can send message with card', function (): void { |
| 61 | + // $token = Authenticator::generateToken('client-id', 'client-secret'); |
| 62 | + $authenticator = new Authenticator('company-id', 'your-channel', 'use $token'); |
| 63 | + $client = new Client($authenticator); |
| 64 | + $message = Message::make([ |
| 65 | + 'text' => 'Check out this notification!', |
| 66 | + 'card' => [ |
| 67 | + 'title' => 'Important Update', |
| 68 | + 'theme' => 'modern-inline', |
| 69 | + 'thumbnail' => 'https://example.com/notification-icon.png', |
| 70 | + ], |
| 71 | + 'buttons' => [ |
| 72 | + [ |
| 73 | + 'label' => 'View Details', |
| 74 | + 'type' => '+', |
| 75 | + 'action' => [ |
| 76 | + 'type' => 'open.url', |
| 77 | + 'data' => [ |
| 78 | + 'web' => 'https://example.com/details', |
| 79 | + ], |
| 80 | + ], |
| 81 | + ], |
| 82 | + ], |
| 83 | + ]); |
| 84 | + |
| 85 | + expect($client) |
| 86 | + ->mock([ |
| 87 | + response(faker()->text()), |
| 88 | + ]) |
| 89 | + ->assertCanSendMessage($message); |
| 90 | +})->group(__DIR__, __FILE__); |
0 commit comments