Add unit tests and abstract bot method execution framework
This commit is contained in:
parent
69f7ff6a5a
commit
7aa6be4e9a
3 changed files with 170 additions and 0 deletions
29
tests/TgBotLib/Methods/GetMeTest.php
Normal file
29
tests/TgBotLib/Methods/GetMeTest.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Objects\Telegram\User;
|
||||
|
||||
class GetMeTest extends TestCase
|
||||
{
|
||||
private $bot;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->bot = new Bot(BOT_TOKEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test checks if the `execute` method of the `getMe` class correctly calls `fromArray` method of User class
|
||||
* and `executeCurl` method of the `getMe` class (itself), with correctly built parameters.
|
||||
*
|
||||
* Method `execute` should return User object constructed from the array returned by `executeCurl`.
|
||||
*/
|
||||
public function testExecute()
|
||||
{
|
||||
$user = getMe::execute($this->bot);
|
||||
$this->assertInstanceOf(User::class, $user);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue