Skip to content

Commit

Permalink
Added InlineKeyboardMarkup support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMY3 committed Mar 17, 2017
1 parent fd69275 commit 230b3be
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 4 deletions.
56 changes: 52 additions & 4 deletions src/Types/Inline/InlineKeyboardMarkup.php
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;
}
}
32 changes: 32 additions & 0 deletions tests/Types/Inline/InlineKeyboardMarkupTest.php
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());
}
}

0 comments on commit 230b3be

Please sign in to comment.