2024-10-06 19:00:33 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace TgBotLib;
|
|
|
|
|
2024-10-07 11:53:25 -04:00
|
|
|
use InvalidArgumentException;
|
2024-10-06 19:00:33 -04:00
|
|
|
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.
|
|
|
|
*/
|
2024-10-07 11:53:25 -04:00
|
|
|
public function getMeTest(): void
|
2024-10-06 19:00:33 -04:00
|
|
|
{
|
2024-10-07 11:53:25 -04:00
|
|
|
$result = $this->bot->getMe();
|
2024-10-06 19:00:33 -04:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|