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
e8a663c9
Commit
e8a663c9
authored
Apr 08, 2017
by
Jack'lul
Committed by
GitHub
Apr 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from noplanman/no_default_commands_fix_tests
No default commands fix tests
parents
89d2f73b
e0c1889a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 addition
and
164 deletions
+1
-164
Telegram.php
src/Telegram.php
+1
-3
CommandTestCase.php
tests/unit/Commands/CommandTestCase.php
+0
-2
EchoCommandTest.php
tests/unit/Commands/UserCommands/EchoCommandTest.php
+0
-68
HelpCommandTest.php
tests/unit/Commands/UserCommands/HelpCommandTest.php
+0
-85
TelegramTest.php
tests/unit/TelegramTest.php
+0
-6
No files found.
src/Telegram.php
View file @
e8a663c9
...
...
@@ -404,8 +404,6 @@ class Telegram
$this
->
addCommandsPath
(
BASE_COMMANDS_PATH
.
'/AdminCommands'
,
false
);
}
$this
->
addCommandsPath
(
BASE_COMMANDS_PATH
.
'/UserCommands'
,
false
);
$type
=
$message
->
getType
();
if
(
$type
===
'command'
)
{
$command
=
$message
->
getCommand
();
...
...
@@ -850,7 +848,7 @@ class Telegram
return
$this
;
}
/**
* Run provided commands
*
...
...
tests/unit/Commands/CommandTestCase.php
View file @
e8a663c9
...
...
@@ -38,8 +38,6 @@ class CommandTestCase extends TestCase
public
function
setUp
()
{
$this
->
telegram
=
new
Telegram
(
'apikey'
,
'testbot'
);
$this
->
telegram
->
addCommandsPath
(
BASE_COMMANDS_PATH
.
'/UserCommands'
);
$this
->
telegram
->
addCommandsPath
(
BASE_PATH
.
'/../examples/Commands'
);
// Add custom commands dedicated to do some tests.
$this
->
telegram
->
addCommandsPath
(
__DIR__
.
'/CustomTestCommands'
);
...
...
tests/unit/Commands/UserCommands/EchoCommandTest.php
deleted
100644 → 0
View file @
89d2f73b
<?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\Commands\UserCommands
;
use
Longman\TelegramBot\Tests\Unit\Commands\CommandTestCase
;
use
Longman\TelegramBot\Tests\Unit\TestHelpers
;
use
Longman\TelegramBot\Commands\UserCommands\EchoCommand
;
/**
* @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
EchoCommandTest
extends
CommandTestCase
{
/**
* setUp
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
command
=
new
EchoCommand
(
$this
->
telegram
);
}
public
function
testEchoCommandProperties
()
{
$this
->
assertAttributeEquals
(
'echo'
,
'name'
,
$this
->
command
);
$this
->
assertAttributeEquals
(
'Show text'
,
'description'
,
$this
->
command
);
$this
->
assertAttributeEquals
(
'/echo <text>'
,
'usage'
,
$this
->
command
);
}
public
function
testEchoCommandExecuteWithoutParameter
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/echo'
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertEquals
(
'Command usage: /echo <text>'
,
$text
);
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/echo '
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertEquals
(
'Command usage: /echo <text>'
,
$text
);
}
public
function
testEchoCommandExecuteWithParameter
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/echo Message!'
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertEquals
(
'Message!'
,
$text
);
}
}
tests/unit/Commands/UserCommands/HelpCommandTest.php
deleted
100644 → 0
View file @
89d2f73b
<?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\Commands\UserCommands
;
use
Longman\TelegramBot\Commands\UserCommands\HelpCommand
;
use
Longman\TelegramBot\Tests\Unit\Commands\CommandTestCase
;
use
Longman\TelegramBot\Tests\Unit\TestHelpers
;
/**
* @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
HelpCommandTest
extends
CommandTestCase
{
/**
* setUp
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
command
=
new
HelpCommand
(
$this
->
telegram
);
}
public
function
testHelpCommandProperties
()
{
$this
->
assertAttributeEquals
(
'help'
,
'name'
,
$this
->
command
);
$this
->
assertAttributeEquals
(
'Show bot commands help'
,
'description'
,
$this
->
command
);
$this
->
assertAttributeEquals
(
'/help or /help <command>'
,
'usage'
,
$this
->
command
);
}
public
function
testHelpCommandExecuteWithoutParameter
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/help'
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertContains
(
'testbot v. '
.
$this
->
telegram
->
getVersion
()
.
"
\n\n
Commands List:"
,
$text
);
}
public
function
testHelpCommandExecuteWithParameterInvalidCommand
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/help invalidcommand'
))
->
execute
()
->
getResult
()
->
getText
();
$this
->
assertEquals
(
'No help available: Command /invalidcommand not found'
,
$text
);
}
public
function
testHelpCommandExecuteWithParameterValidCommand
()
{
$text
=
$this
->
command
->
setUpdate
(
TestHelpers
::
getFakeUpdateCommandObject
(
'/help echo'
))
->
execute
()
->
getResult
()
->
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
);
}
}
tests/unit/TelegramTest.php
View file @
e8a663c9
...
...
@@ -148,10 +148,4 @@ class TelegramTest extends TestCase
$this
->
assertInternalType
(
'array'
,
$commands
);
$this
->
assertNotCount
(
0
,
$commands
);
}
public
function
testGetHelpCommandObject
()
{
$command
=
$this
->
telegram
->
getCommandObject
(
'help'
);
$this
->
assertInstanceOf
(
'Longman\TelegramBot\Commands\UserCommands\HelpCommand'
,
$command
);
}
}
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