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
ffe966b4
Unverified
Commit
ffe966b4
authored
Apr 08, 2017
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix command tests, which don’t apply any more and should be moved to a dedicated repo.
parent
89d2f73b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
160 deletions
+0
-160
CommandTestCase.php
tests/unit/Commands/CommandTestCase.php
+0
-1
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.
tests/unit/Commands/CommandTestCase.php
View file @
ffe966b4
...
...
@@ -39,7 +39,6 @@ class CommandTestCase extends TestCase
{
$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 @
ffe966b4
...
...
@@ -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