-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,62 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: iGusev | ||
* Date: 14/04/16 | ||
* Time: 23:48 | ||
* User: YaroslavMolchan | ||
* Date: 16/03/17 | ||
* Time: 22:15 | ||
*/ | ||
|
||
namespace TelegramBot\Api\Types\Inline; | ||
|
||
class InlineKeyboardMarkup | ||
use TelegramBot\Api\BaseType; | ||
|
||
class InlineKeyboardMarkup extends BaseType | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var array | ||
*/ | ||
static protected $requiredParams = ['inline_keyboard']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var array | ||
*/ | ||
static protected $map = [ | ||
'inline_keyboard' => true, | ||
]; | ||
|
||
/** | ||
* Array of button rows, each represented by an Array of InlineKeyboardButton objects | ||
* Array of Array of InlineKeyboardButton | ||
* | ||
* @var array | ||
*/ | ||
protected $inlineKeyboard; | ||
|
||
/** | ||
* @param array $inlineKeyboard | ||
*/ | ||
public function __construct($inlineKeyboard) | ||
{ | ||
$this->inlineKeyboard = $inlineKeyboard; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getInlineKeyboard() | ||
{ | ||
return $this->inlineKeyboard; | ||
} | ||
|
||
/** | ||
* @param array $inlineKeyboard | ||
*/ | ||
public function setInlineKeyboard($inlineKeyboard) | ||
{ | ||
$this->inlineKeyboard = $inlineKeyboard; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types\Inline; | ||
|
||
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup; | ||
|
||
class InlineKeyboardMarkupTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function testConstructor() | ||
{ | ||
$item = new InlineKeyboardMarkup([[['url' => 'http://test.com', 'text' => 'Link'], ['url' => 'http://test.com', 'text' => 'Link']]]); | ||
|
||
$this->assertAttributeEquals([[['url' => 'http://test.com', 'text' => 'Link'], ['url' => 'http://test.com', 'text' => 'Link']]], 'inlineKeyboard', $item); | ||
} | ||
|
||
public function testSetInlineKeyboard() | ||
{ | ||
$item = new InlineKeyboardMarkup([[['url' => 'http://test.com', 'text' => 'Link'], ['url' => 'http://test.com', 'text' => 'Link']]]); | ||
$item->setInlineKeyboard([[['url' => 'http://test.com', 'text' => 'Link']]]); | ||
|
||
$this->assertAttributeEquals([[['url' => 'http://test.com', 'text' => 'Link']]], 'inlineKeyboard', $item); | ||
} | ||
|
||
public function testGetInlineKeyboard() | ||
{ | ||
$item = new InlineKeyboardMarkup([[['url' => 'http://test.com', 'text' => 'Link'], ['url' => 'http://test.com', 'text' => 'Link']]]); | ||
$item->setInlineKeyboard([[['url' => 'http://test.com', 'text' => 'Link']]]); | ||
|
||
$this->assertEquals([[['url' => 'http://test.com', 'text' => 'Link']]], $item->getInlineKeyboard()); | ||
} | ||
} |