Add unit tests for Bot class
This commit is contained in:
parent
a357451a9d
commit
49db80523f
1 changed files with 43 additions and 0 deletions
43
tests/TgBotLib/BotTest.php
Normal file
43
tests/TgBotLib/BotTest.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BotTest extends TestCase
|
||||
{
|
||||
private $bot;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue