|
2 | 2 |
|
3 | 3 | namespace Telegram\Bot\Laravel\Facades;
|
4 | 4 |
|
| 5 | +use Telegram\Bot\Testing\BotFake; |
5 | 6 | use Illuminate\Support\Facades\Facade;
|
6 | 7 | use Telegram\Bot\BotManager;
|
7 | 8 |
|
8 | 9 | /**
|
9 | 10 | * @see \Telegram\Bot\BotManager
|
10 |
| - * |
11 |
| - * @method static array getBots() |
12 |
| - * @method static null|string getDefaultBotName() |
13 |
| - * @method static \Telegram\Bot\BotManager setDefaultBotName(string $name) |
14 |
| - * @method static \Telegram\Bot\Bot bot(?string $name = null) |
15 |
| - * @method static \Telegram\Bot\Bot reconnect(?string $name = null) |
16 |
| - * @method static \Telegram\Bot\BotManager disconnect(?string $name = null) |
17 |
| - * @method static array getBotConfig(?string $name = null) |
18 |
| - * @method static bool hasContainer() |
19 |
| - * @method static \Illuminate\Contracts\Container\Container getContainer() |
20 |
| - * @method static \Telegram\Bot\BotManager setContainer(\Illuminate\Contracts\Container\Container $container) |
21 |
| - * @method static bool hasConfig($key) |
22 |
| - * @method static void config(array|string|?null $key = null, $default = null) |
23 |
| - * @method static array getConfig() |
24 |
| - * @method static \Telegram\Bot\BotManager setConfig(array $config) |
25 |
| - * |
| 11 | + * @see \Telegram\Bot\Bot |
26 | 12 | * @see \Telegram\Bot\Api
|
27 |
| - * |
28 |
| - * @method static array isLoginAuthDataValid(array $auth_data) |
29 |
| - * @method static void macro($name, $macro) |
30 |
| - * @method static void mixin($mixin, $replace = true) |
31 |
| - * @method static void hasMacro($name) |
32 |
| - * @method static void flushMacros() |
33 |
| - * @method static void macroCall($method, $parameters) |
34 |
| - * @method static \Telegram\Bot\Http\TelegramClient getClient() |
35 |
| - * @method static array getHttpClientConfig() |
36 |
| - * @method static \Telegram\Bot\Api setHttpClientConfig(array $config) |
37 |
| - * @method static string downloadFile(\Telegram\Bot\Objects\File|\Telegram\Bot\Objects\AbstractResponseObject|string $file, string $filename) |
38 |
| - * @method static bool hasToken() |
39 |
| - * @method static string getToken() |
40 |
| - * @method static \Telegram\Bot\Api setToken(string $token) |
41 |
| - * @method static bool banChatMember(array $params) |
42 |
| - * @method static string exportChatInviteLink(array $params) |
43 |
| - * @method static \Telegram\Bot\Objects\ChatInviteLink createChatInviteLink(array $params) |
44 |
| - * @method static \Telegram\Bot\Objects\ChatInviteLink editChatInviteLink(array $params) |
45 |
| - * @method static \Telegram\Bot\Objects\ChatInviteLink revokeChatInviteLink(array $params) |
46 |
| - * @method static bool approveChatJoinRequest(array $params) |
47 |
| - * @method static bool declineChatJoinRequest(array $params) |
48 |
| - * @method static bool setChatPhoto(array $params) |
49 |
| - * @method static bool deleteChatPhoto(array $params) |
50 |
| - * @method static bool setChatTitle(array $params) |
51 |
| - * @method static bool setChatDescription(array $params) |
52 |
| - * @method static bool pinChatMessage(array $params) |
53 |
| - * @method static bool unpinChatMessage(array $params) |
54 |
| - * @method static bool unpinAllChatMessages(array $params) |
55 |
| - * @method static bool leaveChat(array $params) |
56 |
| - * @method static bool unbanChatMember(array $params) |
57 |
| - * @method static bool restrictChatMember(array $params) |
58 |
| - * @method static bool promoteChatMember(array $params) |
59 |
| - * @method static bool setChatAdministratorCustomTitle(array $params) |
60 |
| - * @method static bool banChatSenderChat(array $params) |
61 |
| - * @method static bool unbanChatSenderChat(array $params) |
62 |
| - * @method static bool setChatPermissions(array $params) |
63 |
| - * @method static \Telegram\Bot\Objects\Chat getChat(array $params) |
64 |
| - * @method static array getChatAdministrators(array $params) |
65 |
| - * @method static int getChatMemberCount(array $params) |
66 |
| - * @method static \Telegram\Bot\Objects\ChatMember getChatMember(array $params) |
67 |
| - * @method static bool setChatStickerSet(array $params) |
68 |
| - * @method static bool deleteChatStickerSet(array $params) |
69 |
| - * @method static bool setMyCommands(array $params) |
70 |
| - * @method static bool deleteMyCommands(array $params = []) |
71 |
| - * @method static array getMyCommands(array $params = []) |
72 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool editMessageText(array $params) |
73 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool editMessageCaption(array $params) |
74 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool editMessageMedia(array $params) |
75 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool editMessageReplyMarkup(array $params) |
76 |
| - * @method static \Telegram\Bot\Objects\Updates\Poll stopPoll(array $params) |
77 |
| - * @method static bool deleteMessage(array $params) |
78 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendGame(array $params) |
79 |
| - * @method static \Telegram\Bot\Objects\Updates\Message setGameScore(array $params) |
80 |
| - * @method static array getGameHighScores(array $params) |
81 |
| - * @method static \Telegram\Bot\Objects\User getMe() |
82 |
| - * @method static \Telegram\Bot\Objects\UserProfilePhotos getUserProfilePhotos(array $params) |
83 |
| - * @method static \Telegram\Bot\Objects\File getFile(array $params) |
84 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendLocation(array $params) |
85 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool editMessageLiveLocation(array $params) |
86 |
| - * @method static \Telegram\Bot\Objects\Updates\Message|bool stopMessageLiveLocation(array $params) |
87 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendMessage(array $params) |
88 |
| - * @method static \Telegram\Bot\Objects\Updates\Message forwardMessage(array $params) |
89 |
| - * @method static int copyMessage(array $params) |
90 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendPhoto(array $params) |
91 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendAudio(array $params) |
92 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendDocument(array $params) |
93 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendVideo(array $params) |
94 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendAnimation(array $params) |
95 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendVoice(array $params) |
96 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendVideoNote(array $params) |
97 |
| - * @method static array sendMediaGroup(array $params) |
98 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendVenue(array $params) |
99 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendContact(array $params) |
100 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendPoll(array $params) |
101 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendDice(array $params) |
102 |
| - * @method static bool sendChatAction(array $params) |
103 |
| - * @method static bool setPassportDataErrors(array $params) |
104 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendInvoice(array $params) |
105 |
| - * @method static bool answerShippingQuery(array $params) |
106 |
| - * @method static bool answerPreCheckoutQuery(array $params) |
107 |
| - * @method static bool answerCallbackQuery(array $params) |
108 |
| - * @method static bool answerInlineQuery(array $params) |
109 |
| - * @method static \Telegram\Bot\Objects\Updates\Message sendSticker(array $params) |
110 |
| - * @method static \Telegram\Bot\Objects\StickerSet getStickerSet(array $params) |
111 |
| - * @method static \Telegram\Bot\Objects\File uploadStickerFile(array $params) |
112 |
| - * @method static bool createNewStickerSet(array $params) |
113 |
| - * @method static bool addStickerToSet(array $params) |
114 |
| - * @method static bool setStickerPositionInSet(array $params) |
115 |
| - * @method static bool deleteStickerFromSet(array $params) |
116 |
| - * @method static bool setStickerSetThumb(array $params) |
117 |
| - * @method static array getUpdates(array $params = []) |
118 |
| - * @method static array confirmUpdate(int $highestId) |
119 |
| - * @method static bool setWebhook(array $params) |
120 |
| - * @method static bool deleteWebhook() |
121 |
| - * @method static \Telegram\Bot\Objects\WebhookInfo getWebhookInfo() |
122 |
| - * @method static \Telegram\Bot\Objects\Update getWebhookUpdate() |
123 |
| - * @method static bool removeWebhook() |
124 |
| - * @method static bool logOut() |
125 |
| - * @method static bool close() |
126 |
| - * |
127 |
| - * @see \Telegram\Bot\Commands\CommandBus |
128 |
| - * |
129 |
| - * @method static array getCommands() |
130 |
| - * @method static \Telegram\Bot\Commands\CommandBus addCommands(array|string $commands) |
131 |
| - * @method static \Telegram\Bot\Commands\CommandBus addCommand(string $command, \Telegram\Bot\Commands\CommandInterface|string $commandClass) |
132 |
| - * @method static \Telegram\Bot\Commands\CommandBus removeCommand(string $name) |
133 |
| - * @method static \Telegram\Bot\Commands\CommandBus removeCommands(array $names) |
134 |
| - * @method static string parseCommand(string $text, int $offset, int $length) |
135 |
| - * @method static \Telegram\Bot\Objects\Update handler(\Telegram\Bot\Objects\Update $update) |
136 |
| - * @method static void execute(\Telegram\Bot\Commands\CommandInterface|string $commandName, \Telegram\Bot\Objects\Update $update, \Telegram\Bot\Objects\MessageEntity|array $entity, bool $isTriggered = false) |
137 |
| - * @method static \Telegram\Bot\Commands\CommandInterface resolveCommand($command) |
138 |
| - * @method static bool hasBot() |
139 |
| - * @method static null|\Telegram\Bot\Bot getBot() |
140 |
| - * @method static \Telegram\Bot\Commands\CommandBus setBot(\Telegram\Bot\Bot $bot) |
141 | 13 | */
|
142 | 14 | class Telegram extends Facade
|
143 | 15 | {
|
| 16 | + /** |
| 17 | + * Replace the bound instance with a fake. |
| 18 | + * |
| 19 | + * @param array $responses |
| 20 | + * |
| 21 | + * @return BotFake |
| 22 | + */ |
| 23 | + public static function fake(array $responses = []): BotFake |
| 24 | + { |
| 25 | + return tap(new BotFake($responses), static fn ($fake) => static::swap($fake)); |
| 26 | + } |
| 27 | + |
144 | 28 | /**
|
145 | 29 | * Get the registered name of the component.
|
146 | 30 | */
|
|
0 commit comments