From 230b3be5d741c89cf79c625d5b2c6cf4ffc3c9c1 Mon Sep 17 00:00:00 2001 From: Yaroslav Molchan Date: Fri, 17 Mar 2017 10:24:34 +0200 Subject: [PATCH] Added InlineKeyboardMarkup support --- src/Types/Inline/InlineKeyboardMarkup.php | 56 +++++++++++++++++-- .../Types/Inline/InlineKeyboardMarkupTest.php | 32 +++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 tests/Types/Inline/InlineKeyboardMarkupTest.php diff --git a/src/Types/Inline/InlineKeyboardMarkup.php b/src/Types/Inline/InlineKeyboardMarkup.php index b34d06b3..92a5b270 100644 --- a/src/Types/Inline/InlineKeyboardMarkup.php +++ b/src/Types/Inline/InlineKeyboardMarkup.php @@ -1,14 +1,62 @@ 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; + } } diff --git a/tests/Types/Inline/InlineKeyboardMarkupTest.php b/tests/Types/Inline/InlineKeyboardMarkupTest.php new file mode 100644 index 00000000..0eb05a09 --- /dev/null +++ b/tests/Types/Inline/InlineKeyboardMarkupTest.php @@ -0,0 +1,32 @@ + '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()); + } +}