|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace TelegramBot\Api\Test; |
| 4 | + |
| 5 | +use TelegramBot\Api\Types\BotCommand; |
| 6 | + |
| 7 | +class BotCommandTest extends \PHPUnit_Framework_TestCase |
| 8 | +{ |
| 9 | + public function testSetCommand() |
| 10 | + { |
| 11 | + $item = new BotCommand(); |
| 12 | + $item->setCommand('start'); |
| 13 | + $this->assertAttributeEquals('start', 'command', $item); |
| 14 | + } |
| 15 | + |
| 16 | + public function testGetCommand() |
| 17 | + { |
| 18 | + $item = new BotCommand(); |
| 19 | + $item->setCommand('start'); |
| 20 | + $this->assertEquals('start', $item->getCommand()); |
| 21 | + } |
| 22 | + |
| 23 | + public function testSetDescription() |
| 24 | + { |
| 25 | + $item = new BotCommand(); |
| 26 | + $item->setDescription('This is a start command!'); |
| 27 | + $this->assertAttributeEquals('This is a start command!', 'description', $item); |
| 28 | + } |
| 29 | + |
| 30 | + public function testGetDescription() |
| 31 | + { |
| 32 | + $item = new BotCommand(); |
| 33 | + $item->setDescription('This is a start command!'); |
| 34 | + $this->assertEquals('This is a start command!', $item->getDescription()); |
| 35 | + } |
| 36 | + |
| 37 | + public function testFromResponse() |
| 38 | + { |
| 39 | + $botCommand = BotCommand::fromResponse( |
| 40 | + [ |
| 41 | + 'command' => 'start', |
| 42 | + 'description' => 'This is a start command!', |
| 43 | + ] |
| 44 | + ); |
| 45 | + |
| 46 | + $this->assertInstanceOf('\TelegramBot\Api\Types\BotCommand', $botCommand); |
| 47 | + $this->assertEquals('start', $botCommand->getCommand()); |
| 48 | + $this->assertEquals('This is a start command!', $botCommand->getDescription()); |
| 49 | + } |
| 50 | +} |
0 commit comments