Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F631292
KeyboardButtonTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
KeyboardButtonTest.php
View Options
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Longman
\
TelegramBot
\
Tests
\
Unit
;
use
Longman
\
TelegramBot
\
Entities
\
KeyboardButton
;
/**
* @package TelegramTest
* @author Avtandil Kikabidze <akalongman@gmail.com>
* @copyright Avtandil Kikabidze <akalongman@gmail.com>
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
* @link http://www.github.com/akalongman/php-telegram-bot
*/
class
KeyboardButtonTest
extends
TestCase
{
/**
* @expectedException \Longman\TelegramBot\Exception\TelegramException
* @expectedExceptionMessage You must add some text to the button!
*/
public
function
testKeyboardButtonNoTextFail
(
)
{
new
KeyboardButton
(
[
]
)
;
}
/**
* @expectedException \Longman\TelegramBot\Exception\TelegramException
* @expectedExceptionMessage You must use only one of these fields: request_contact, request_location!
*/
public
function
testKeyboardButtonTooManyParametersFail
(
)
{
new
KeyboardButton
(
[
'text'
=>
'message'
,
'request_contact'
=>
true
,
'request_location'
=>
true
]
)
;
}
public
function
testKeyboardButtonSuccess
(
)
{
new
KeyboardButton
(
[
'text'
=>
'message'
]
)
;
new
KeyboardButton
(
[
'text'
=>
'message'
,
'request_contact'
=>
true
]
)
;
new
KeyboardButton
(
[
'text'
=>
'message'
,
'request_location'
=>
true
]
)
;
}
public
function
testInlineKeyboardButtonCouldBe
(
)
{
self
::
assertTrue
(
KeyboardButton
::
couldBe
(
[
'text'
=>
'message'
]
)
)
;
self
::
assertFalse
(
KeyboardButton
::
couldBe
(
[
'no_text'
=>
'message'
]
)
)
;
}
public
function
testKeyboardButtonParameterSetting
(
)
{
$button
=
new
KeyboardButton
(
'message'
)
;
self
::
assertEmpty
(
$button
->
getRequestContact
(
)
)
;
self
::
assertEmpty
(
$button
->
getRequestLocation
(
)
)
;
$button
->
setRequestContact
(
true
)
;
self
::
assertTrue
(
$button
->
getRequestContact
(
)
)
;
self
::
assertEmpty
(
$button
->
getRequestLocation
(
)
)
;
$button
->
setRequestLocation
(
true
)
;
self
::
assertEmpty
(
$button
->
getRequestContact
(
)
)
;
self
::
assertTrue
(
$button
->
getRequestLocation
(
)
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 15, 11:37 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
134342
Default Alt Text
KeyboardButtonTest.php (2 KB)
Attached To
Mode
R123 php-telegram-bot
Attached
Detach File
Event Timeline