Add copyMessages method for bulk message copying
This commit is contained in:
parent
ebea95b930
commit
294b25ad26
4 changed files with 120 additions and 0 deletions
55
tests/TgBotLib/Methods/CopyMessagesTest.php
Normal file
55
tests/TgBotLib/Methods/CopyMessagesTest.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Types\ParseMode;
|
||||
use TgBotLib\Objects\LinkPreviewOptions;
|
||||
use TgBotLib\Objects\Message;
|
||||
use TgBotLib\Objects\MessageId;
|
||||
|
||||
class CopyMessagesTest extends TestCase
|
||||
{
|
||||
private static Bot $bot;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$bot = new Bot(BOT_TOKEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the `sendMessage` function of the bot instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCopyMessage(): void
|
||||
{
|
||||
$message1 = self::$bot->sendMessage(
|
||||
chat_id: TEST_CHAT_ID,
|
||||
text: "Test Message 1"
|
||||
);
|
||||
|
||||
$message2 = self::$bot->sendMessage(
|
||||
chat_id: TEST_CHAT_ID,
|
||||
text: "Test Message 2"
|
||||
);
|
||||
|
||||
$result = self::$bot->copyMessages(
|
||||
chat_id: TEST_CHAT_ID,
|
||||
from_chat_id: TEST_CHAT_ID,
|
||||
message_ids: [$message1->getMessageId(), $message2->getMessageId()]
|
||||
);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertCount(2, $result);
|
||||
foreach ($result as $messageId)
|
||||
{
|
||||
$this->assertInstanceOf(MessageId::class, $messageId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue