Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
1528fe52
Commit
1528fe52
authored
Mar 12, 2017
by
Marcel
Committed by
GitHub
Mar 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from noplanman/help_show_tests
Add tests for commands shown in help command.
parents
98bafec9
238402ef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
1 deletion
+133
-1
CommandTest.php
tests/unit/Commands/CommandTest.php
+6
-0
CommandTestCase.php
tests/unit/Commands/CommandTestCase.php
+3
-0
HiddenCommand.php
tests/unit/Commands/CustomTestCommands/HiddenCommand.php
+56
-0
VisibleCommand.php
tests/unit/Commands/CustomTestCommands/VisibleCommand.php
+56
-0
HelpCommandTest.php
tests/unit/Commands/UserCommands/HelpCommandTest.php
+12
-1
No files found.
tests/unit/Commands/CommandTest.php
View file @
1528fe52
...
...
@@ -127,6 +127,12 @@ class CommandTest extends TestCase
$this
->
assertTrue
(
$this
->
command_stub
->
isEnabled
());
}
public
function
testDefaultCommandShownInHelp
()
{
$this
->
assertAttributeEquals
(
true
,
'show_in_help'
,
$this
->
command_stub
);
$this
->
assertTrue
(
$this
->
command_stub
->
showInHelp
());
}
public
function
testDefaultCommandNeedsMysql
()
{
$this
->
assertAttributeEquals
(
false
,
'need_mysql'
,
$this
->
command_stub
);
...
...
tests/unit/Commands/CommandTestCase.php
View file @
1528fe52
...
...
@@ -39,6 +39,9 @@ class CommandTestCase extends TestCase
{
$this
->
telegram
=
new
Telegram
(
'apikey'
,
'testbot'
);
$this
->
telegram
->
addCommandsPath
(
BASE_COMMANDS_PATH
.
'/UserCommands'
);
// Add custom commands dedicated to do some tests.
$this
->
telegram
->
addCommandsPath
(
__DIR__
.
'/CustomTestCommands'
);
$this
->
telegram
->
getCommandsList
();
}
...
...
tests/unit/Commands/CustomTestCommands/HiddenCommand.php
0 → 100644
View file @
1528fe52
<?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\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
/**
* Test "/hidden" command to test $show_in_help
*/
class
HiddenCommand
extends
UserCommand
{
/**
* @var string
*/
protected
$name
=
'hidden'
;
/**
* @var string
*/
protected
$description
=
'This command is hidden in help'
;
/**
* @var string
*/
protected
$usage
=
'/hidden'
;
/**
* @var string
*/
protected
$version
=
'1.0.0'
;
/**
* @var bool
*/
protected
$show_in_help
=
false
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
return
Request
::
emptyResponse
();
}
}
tests/unit/Commands/CustomTestCommands/VisibleCommand.php
0 → 100644
View file @
1528fe52
<?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\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommand
;
use
Longman\TelegramBot\Request
;
/**
* Test "/visible" command to test $show_in_help
*/
class
VisibleCommand
extends
UserCommand
{
/**
* @var string
*/
protected
$name
=
'visible'
;
/**
* @var string
*/
protected
$description
=
'This command is visible in help'
;
/**
* @var string
*/
protected
$usage
=
'/visible'
;
/**
* @var string
*/
protected
$version
=
'1.0.0'
;
/**
* @var bool
*/
protected
$show_in_help
=
true
;
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
function
execute
()
{
return
Request
::
emptyResponse
();
}
}
tests/unit/Commands/UserCommands/HelpCommandTest.php
View file @
1528fe52
...
...
@@ -10,9 +10,9 @@
namespace
Longman\TelegramBot\Tests\Unit\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommands\HelpCommand
;
use
Longman\TelegramBot\Tests\Unit\Commands\CommandTestCase
;
use
Longman\TelegramBot\Tests\Unit\TestHelpers
;
use
Longman\TelegramBot\Commands\UserCommands\HelpCommand
;
/**
* @package TelegramTest
...
...
@@ -71,4 +71,15 @@ class HelpCommandTest extends CommandTestCase
->
getText
();
$this
->
assertContains
(
"Description: Show text
\n
Usage: /echo <text>"
,
$text
);
}
public
function
testHelpCommandWithHiddenCommand
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/help'
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertContains
(
'/visible'
,
$text
);
$this
->
assertNotContains
(
'/hidden'
,
$text
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment