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
a00e6914
Unverified
Commit
a00e6914
authored
Jul 06, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove all superfluous `@test` comments and rename functions to start with `test`.
parent
61cc1a44
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
21 additions
and
197 deletions
+21
-197
CommandTest.php
tests/Unit/Commands/CommandTest.php
+0
-39
CommandTestCase.php
tests/Unit/Commands/CommandTestCase.php
+0
-2
EchoCommandTest.php
tests/Unit/Commands/UserCommands/EchoCommandTest.php
+0
-9
HelpCommandTest.php
tests/Unit/Commands/UserCommands/HelpCommandTest.php
+0
-12
ConversationTest.php
tests/Unit/ConversationTest.php
+9
-34
ChatTest.php
tests/Unit/Entities/ChatTest.php
+1
-5
MessageTest.php
tests/Unit/Entities/MessageTest.php
+0
-3
ServerResponseTest.php
tests/Unit/Entities/ServerResponseTest.php
+0
-43
UpdateTest.php
tests/Unit/Entities/UpdateTest.php
+0
-4
TelegramLogTest.php
tests/Unit/TelegramLogTest.php
+3
-18
TelegramTest.php
tests/Unit/TelegramTest.php
+8
-28
No files found.
tests/Unit/Commands/CommandTest.php
View file @
a00e6914
...
...
@@ -48,9 +48,6 @@ class CommandTest extends TestCase
$this
->
command_stub_with_config
->
__construct
(
$this
->
telegram_with_config
);
}
/**
* @test
*/
public
function
testCommandConstructorNeedsTelegramObject
()
{
$error_message
=
'must be an instance of Longman\TelegramBot\Telegram'
;
...
...
@@ -72,87 +69,57 @@ class CommandTest extends TestCase
}
}
/**
* @test
*/
public
function
testCommandHasCorrectTelegramObject
()
{
$this
->
assertAttributeEquals
(
$this
->
telegram
,
'telegram'
,
$this
->
command_stub
);
$this
->
assertSame
(
$this
->
telegram
,
$this
->
command_stub
->
getTelegram
());
}
/**
* @test
*/
public
function
testDefaultCommandName
()
{
$this
->
assertAttributeEquals
(
''
,
'name'
,
$this
->
command_stub
);
$this
->
assertEmpty
(
$this
->
command_stub
->
getName
());
}
/**
* @test
*/
public
function
testDefaultCommandDescription
()
{
$this
->
assertAttributeEquals
(
'Command description'
,
'description'
,
$this
->
command_stub
);
$this
->
assertEquals
(
'Command description'
,
$this
->
command_stub
->
getDescription
());
}
/**
* @test
*/
public
function
testDefaultCommandUsage
()
{
$this
->
assertAttributeEquals
(
'Command usage'
,
'usage'
,
$this
->
command_stub
);
$this
->
assertEquals
(
'Command usage'
,
$this
->
command_stub
->
getUsage
());
}
/**
* @test
*/
public
function
testDefaultCommandVersion
()
{
$this
->
assertAttributeEquals
(
'1.0.0'
,
'version'
,
$this
->
command_stub
);
$this
->
assertEquals
(
'1.0.0'
,
$this
->
command_stub
->
getVersion
());
}
/**
* @test
*/
public
function
testDefaultCommandIsEnabled
()
{
$this
->
assertAttributeEquals
(
true
,
'enabled'
,
$this
->
command_stub
);
$this
->
assertTrue
(
$this
->
command_stub
->
isEnabled
());
}
/**
* @test
*/
public
function
testDefaultCommandNeedsMysql
()
{
$this
->
assertAttributeEquals
(
false
,
'need_mysql'
,
$this
->
command_stub
);
}
/**
* @test
*/
public
function
testDefaultCommandEmptyConfig
()
{
$this
->
assertAttributeEquals
([],
'config'
,
$this
->
command_stub
);
}
/**
* @test
*/
public
function
testDefaultCommandUpdateNull
()
{
$this
->
assertAttributeEquals
(
null
,
'update'
,
$this
->
command_stub
);
}
/**
* @test
*/
public
function
testCommandSetUpdateAndMessage
()
{
$stub
=
$this
->
command_stub
;
...
...
@@ -174,17 +141,11 @@ class CommandTest extends TestCase
$this
->
assertEquals
(
$message
,
$stub
->
getMessage
());
}
/**
* @test
*/
public
function
testCommandWithConfigNotEmptyConfig
()
{
$this
->
assertAttributeNotEmpty
(
'config'
,
$this
->
command_stub_with_config
);
}
/**
* @test
*/
public
function
testCommandWithConfigCorrectConfig
()
{
$this
->
assertAttributeEquals
([
'config_key'
=>
'config_value'
],
'config'
,
$this
->
command_stub_with_config
);
...
...
tests/Unit/Commands/CommandTestCase.php
View file @
a00e6914
...
...
@@ -34,8 +34,6 @@ class CommandTestCase extends TestCase
/**
* Make sure the version number is in the format x.x.x, x.x or x
*
* @test
*/
public
function
testVersionNumberFormat
()
{
...
...
tests/Unit/Commands/UserCommands/EchoCommandTest.php
View file @
a00e6914
...
...
@@ -30,9 +30,6 @@ class EchoCommandTest extends CommandTestCase
$this
->
command
=
new
EchoCommand
(
$this
->
telegram
);
}
/**
* @test
*/
public
function
testEchoCommandProperties
()
{
$this
->
assertAttributeEquals
(
'echo'
,
'name'
,
$this
->
command
);
...
...
@@ -40,9 +37,6 @@ class EchoCommandTest extends CommandTestCase
$this
->
assertAttributeEquals
(
'/echo <text>'
,
'usage'
,
$this
->
command
);
}
/**
* @test
*/
public
function
testEchoCommandExecuteWithoutParameter
()
{
$text
=
$this
->
command
...
...
@@ -60,9 +54,6 @@ class EchoCommandTest extends CommandTestCase
$this
->
assertEquals
(
'Command usage: /echo <text>'
,
$text
);
}
/**
* @test
*/
public
function
testEchoCommandExecuteWithParameter
()
{
$text
=
$this
->
command
...
...
tests/Unit/Commands/UserCommands/HelpCommandTest.php
View file @
a00e6914
...
...
@@ -29,9 +29,6 @@ class HelpCommandTest extends CommandTestCase
$this
->
command
=
new
HelpCommand
(
$this
->
telegram
);
}
/**
* @test
*/
public
function
testHelpCommandProperties
()
{
$this
->
assertAttributeEquals
(
'help'
,
'name'
,
$this
->
command
);
...
...
@@ -39,9 +36,6 @@ class HelpCommandTest extends CommandTestCase
$this
->
assertAttributeEquals
(
'/help or /help <command>'
,
'usage'
,
$this
->
command
);
}
/**
* @test
*/
public
function
testHelpCommandExecuteWithoutParameter
()
{
$text
=
$this
->
command
...
...
@@ -55,9 +49,6 @@ class HelpCommandTest extends CommandTestCase
);
}
/**
* @test
*/
public
function
testHelpCommandExecuteWithParameterInvalidCommand
()
{
$text
=
$this
->
command
...
...
@@ -68,9 +59,6 @@ class HelpCommandTest extends CommandTestCase
$this
->
assertEquals
(
'No help available: Command /invalidcommand not found'
,
$text
);
}
/**
* @test
*/
public
function
testHelpCommandExecuteWithParameterValidCommand
()
{
$text
=
$this
->
command
...
...
tests/Unit/ConversationTest.php
View file @
a00e6914
...
...
@@ -47,10 +47,7 @@ class ConversationTest extends TestCase
TestHelpers
::
emptyDB
(
$credentials
);
}
/**
* @test
*/
public
function
conversationThatDoesntExistPropertiesSetCorrectly
()
public
function
testConversationThatDoesntExistPropertiesSetCorrectly
()
{
$conversation
=
new
Conversation
(
123
,
456
);
$this
->
assertAttributeEquals
(
123
,
'user_id'
,
$conversation
);
...
...
@@ -58,10 +55,7 @@ class ConversationTest extends TestCase
$this
->
assertAttributeEquals
(
null
,
'command'
,
$conversation
);
}
/**
* @test
*/
public
function
conversationThatExistsPropertiesSetCorrectly
()
public
function
testConversationThatExistsPropertiesSetCorrectly
()
{
$info
=
TestHelpers
::
startFakeConversation
(
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
...
...
@@ -70,10 +64,7 @@ class ConversationTest extends TestCase
$this
->
assertAttributeEquals
(
'command'
,
'command'
,
$conversation
);
}
/**
* @test
*/
public
function
conversationThatDoesntExistWithoutCommand
()
public
function
testConversationThatDoesntExistWithoutCommand
()
{
$conversation
=
new
Conversation
(
1
,
1
);
$this
->
assertFalse
(
$conversation
->
exists
());
...
...
@@ -81,18 +72,14 @@ class ConversationTest extends TestCase
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramException
*/
public
function
c
onversationThatDoesntExistWithCommand
()
public
function
testC
onversationThatDoesntExistWithCommand
()
{
new
Conversation
(
1
,
1
,
'command'
);
}
/**
* @test
*/
public
function
newConversationThatWontExistWithoutCommand
()
public
function
testNewConversationThatWontExistWithoutCommand
()
{
TestHelpers
::
startFakeConversation
(
null
);
$conversation
=
new
Conversation
(
0
,
0
);
...
...
@@ -100,10 +87,7 @@ class ConversationTest extends TestCase
$this
->
assertNull
(
$conversation
->
getCommand
());
}
/**
* @test
*/
public
function
newConversationThatWillExistWithCommand
()
public
function
testNewConversationThatWillExistWithCommand
()
{
$info
=
TestHelpers
::
startFakeConversation
(
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
...
...
@@ -111,10 +95,7 @@ class ConversationTest extends TestCase
$this
->
assertEquals
(
'command'
,
$conversation
->
getCommand
());
}
/**
* @test
*/
public
function
stopConversation
()
public
function
testStopConversation
()
{
$info
=
TestHelpers
::
startFakeConversation
(
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
...
...
@@ -125,10 +106,7 @@ class ConversationTest extends TestCase
$this
->
assertFalse
(
$conversation2
->
exists
());
}
/**
* @test
*/
public
function
cancelConversation
()
public
function
testCancelConversation
()
{
$info
=
TestHelpers
::
startFakeConversation
(
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
...
...
@@ -139,10 +117,7 @@ class ConversationTest extends TestCase
$this
->
assertFalse
(
$conversation2
->
exists
());
}
/**
* @test
*/
public
function
updateConversationNotes
()
public
function
testUpdateConversationNotes
()
{
$info
=
TestHelpers
::
startFakeConversation
(
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
...
...
tests/Unit/Entities/ChatTest.php
View file @
a00e6914
...
...
@@ -33,11 +33,7 @@ class ChatTest extends TestCase
{
}
/**
* @test
*/
public
function
testChatType
()
public
function
testChatType
()
{
$this
->
chat
=
new
Chat
(
json_decode
(
'{"id":123,"title":null,"first_name":"john","last_name":null,"username":"null"}'
,
true
));
...
...
tests/Unit/Entities/MessageTest.php
View file @
a00e6914
...
...
@@ -40,9 +40,6 @@ class MessageTest extends TestCase
//$json = utf8_encode($json);
return
json_decode
(
$json
,
true
);
}
/**
* @test
*/
public
function
testTextAndCommandRecognise
()
{
// /command
...
...
tests/Unit/Entities/ServerResponseTest.php
View file @
a00e6914
...
...
@@ -37,10 +37,6 @@ class ServerResponseTest extends TestCase
{
}
/**
* @test
*/
public
function
sendMessageOk
()
{
return
'{
...
...
@@ -80,10 +76,6 @@ class ServerResponseTest extends TestCase
}
/**
* @test
*/
public
function
sendMessageFail
()
{
return
'{
...
...
@@ -105,10 +97,6 @@ class ServerResponseTest extends TestCase
$this
->
assertEquals
(
'Error: Bad Request: wrong chat id'
,
$this
->
server
->
getDescription
());
}
/**
* @test
*/
public
function
setWebHookOk
()
{
return
'{"ok":true,"result":true,"description":"Webhook was set"}'
;
...
...
@@ -126,10 +114,6 @@ class ServerResponseTest extends TestCase
$this
->
assertEquals
(
'Webhook was set'
,
$this
->
server
->
getDescription
());
}
/**
* @test
*/
public
function
setWebHookFail
()
{
return
'{
...
...
@@ -152,12 +136,6 @@ class ServerResponseTest extends TestCase
$this
->
assertEquals
(
"Error: Bad request: htttps://domain.host.org/dir/hook.php"
,
$this
->
server
->
getDescription
());
}
/**
* @test
*/
public
function
getUpdatesArray
()
{
return
'{
...
...
@@ -210,10 +188,6 @@ class ServerResponseTest extends TestCase
$this
->
assertInstanceOf
(
'\Longman\TelegramBot\Entities\Update'
,
$this
->
server
->
getResult
()[
0
]);
}
/**
* @test
*/
public
function
getUpdatesEmpty
()
{
return
'{"ok":true,"result":[]}'
;
...
...
@@ -226,12 +200,6 @@ class ServerResponseTest extends TestCase
$this
->
assertNull
(
$this
->
server
->
getResult
());
}
/**
* @test
*/
public
function
getUserProfilePhotos
()
{
return
'{
...
...
@@ -273,12 +241,6 @@ class ServerResponseTest extends TestCase
}
/**
* @test
*/
public
function
getFile
()
{
return
'{
...
...
@@ -303,11 +265,6 @@ class ServerResponseTest extends TestCase
}
/**
* @test
*/
public
function
testSetGeneralTestFakeResponse
()
{
//setWebhook ok
$fake_response
=
Request
::
generateGeneralFakeServerResponse
();
...
...
tests/Unit/Entities/UpdateTest.php
View file @
a00e6914
...
...
@@ -26,10 +26,6 @@ class UpdateTest extends TestCase
*/
private
$update
;
/**
* @test
*/
public
function
testUpdateCast
()
{
$json
=
'
...
...
tests/Unit/TelegramLogTest.php
View file @
a00e6914
...
...
@@ -56,35 +56,29 @@ class TelegramLogTest extends TestCase
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramLogException
*/
public
function
n
ewInstanceWithoutErrorPath
()
public
function
testN
ewInstanceWithoutErrorPath
()
{
TelegramLog
::
initErrorLog
(
''
);
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramLogException
*/
public
function
n
ewInstanceWithoutDebugPath
()
public
function
testN
ewInstanceWithoutDebugPath
()
{
TelegramLog
::
initDebugLog
(
''
);
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramLogException
*/
public
function
n
ewInstanceWithoutUpdatePath
()
public
function
testN
ewInstanceWithoutUpdatePath
()
{
TelegramLog
::
initUpdateLog
(
''
);
}
/**
* @test
*/
public
function
testErrorStream
()
{
$file
=
$this
->
logfiles
[
'error'
];
...
...
@@ -95,9 +89,6 @@ class TelegramLogTest extends TestCase
$this
->
assertContains
(
'bot_log.ERROR: my error'
,
file_get_contents
(
$file
));
}
/**
* @test
*/
public
function
testDebugStream
()
{
$file
=
$this
->
logfiles
[
'debug'
];
...
...
@@ -108,9 +99,6 @@ class TelegramLogTest extends TestCase
$this
->
assertContains
(
'bot_log.DEBUG: my debug'
,
file_get_contents
(
$file
));
}
/**
* @test
*/
public
function
testUpdateStream
()
{
$file
=
$this
->
logfiles
[
'update'
];
...
...
@@ -121,9 +109,6 @@ class TelegramLogTest extends TestCase
$this
->
assertContains
(
'my update'
,
file_get_contents
(
$file
));
}
/**
* @test
*/
public
function
testExternalStream
()
{
$file
=
$this
->
logfiles
[
'external'
];
...
...
tests/Unit/TelegramTest.php
View file @
a00e6914
...
...
@@ -60,43 +60,32 @@ class TelegramTest extends TestCase
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramException
*/
public
function
n
ewInstanceWithoutApiKeyParam
()
public
function
testN
ewInstanceWithoutApiKeyParam
()
{
new
Telegram
(
null
,
'testbotname'
);
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramException
*/
public
function
n
ewInstanceWithoutBotNameParam
()
public
function
testN
ewInstanceWithoutBotNameParam
()
{
new
Telegram
(
'testapikey'
,
null
);
}
/**
* @test
*/
public
function
getApiKey
()
public
function
testGetApiKey
()
{
$this
->
assertEquals
(
'testapikey'
,
$this
->
telegram
->
getApiKey
());
}
/**
* @test
*/
public
function
getBotName
()
public
function
testGetBotName
()
{
$this
->
assertEquals
(
'testbotname'
,
$this
->
telegram
->
getBotName
());
}
/**
* @test
*/
public
function
enableAdmins
()
public
function
testEnableAdmins
()
{
$tg
=
&
$this
->
telegram
;
...
...
@@ -115,10 +104,7 @@ class TelegramTest extends TestCase
$this
->
assertCount
(
3
,
$tg
->
getAdminList
());
}
/**
* @test
*/
public
function
addCustomCommandsPaths
()
public
function
testAddCustomCommandsPaths
()
{
$tg
=
&
$this
->
telegram
;
...
...
@@ -140,20 +126,14 @@ class TelegramTest extends TestCase
$this
->
assertAttributeCount
(
4
,
'commands_paths'
,
$tg
);
}
/**
* @test
*/
public
function
getCommandsList
()
public
function
testGetCommandsList
()
{
$commands
=
$this
->
telegram
->
getCommandsList
();
$this
->
assertInternalType
(
'array'
,
$commands
);
$this
->
assertNotCount
(
0
,
$commands
);
}
/**
* @test
*/
public
function
getHelpCommandObject
()
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