From 49db80523f49beffa2d2820c968c39978e28843d Mon Sep 17 00:00:00 2001 From: netkas Date: Sun, 6 Oct 2024 19:00:33 -0400 Subject: [PATCH] Add unit tests for Bot class --- tests/TgBotLib/BotTest.php | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/TgBotLib/BotTest.php diff --git a/tests/TgBotLib/BotTest.php b/tests/TgBotLib/BotTest.php new file mode 100644 index 0000000..1932fd6 --- /dev/null +++ b/tests/TgBotLib/BotTest.php @@ -0,0 +1,43 @@ +bot = new Bot(BOT_TOKEN); + } + + /** + * Test sendRequest method of Bot class + * for valid method and parameters. + */ + public function testSendRequestValid(): void + { + $method = 'getMe'; + $parameters = ['text' => 'test message']; + + // assuming that sendMessage method is properly working + $result = $this->bot->sendRequest($method, $parameters); + + $this->assertIsArray($result); + } + + /** + * Test sendRequest method of Bot class + * for invalid method. + */ + public function testSendRequestInvalidMethod(): void + { + $method = 'invalidMethod'; + $parameters = []; + + $this->expectException(InvalidArgumentException::class); + + $this->bot->sendRequest($method, $parameters); + } +} \ No newline at end of file