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
ce439368
Unverified
Commit
ce439368
authored
Jun 13, 2019
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor code style fixes, remove unused `use` definitions, set YAML indentation to 2
parent
fd813acc
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
69 additions
and
70 deletions
+69
-70
.editorconfig
.editorconfig
+3
-0
.scrutinizer.yml
.scrutinizer.yml
+17
-17
phpunit.xml.dist
phpunit.xml.dist
+21
-21
DebugCommand.php
src/Commands/AdminCommands/DebugCommand.php
+8
-8
GenericCommand.php
src/Commands/SystemCommands/GenericCommand.php
+0
-1
GenericmessageCommand.php
src/Commands/SystemCommands/GenericmessageCommand.php
+1
-1
InlinequeryCommand.php
src/Commands/SystemCommands/InlinequeryCommand.php
+0
-2
StartCommand.php
src/Commands/SystemCommands/StartCommand.php
+0
-1
Keyboard.php
src/Entities/Keyboard.php
+1
-1
Telegram.php
src/Telegram.php
+3
-3
ConversationTest.php
tests/unit/ConversationTest.php
+6
-6
ServerResponseTest.php
tests/unit/Entities/ServerResponseTest.php
+4
-4
TestHelpers.php
tests/unit/TestHelpers.php
+1
-1
importFromLog.php
utils/importFromLog.php
+4
-4
No files found.
.editorconfig
View file @
ce439368
...
@@ -7,3 +7,6 @@ charset = utf-8
...
@@ -7,3 +7,6 @@ charset = utf-8
indent_style = space
indent_style = space
indent_size = 4
indent_size = 4
trim_trailing_whitespace = true
trim_trailing_whitespace = true
[*.{yml, yaml}]
indent_size = 2
.scrutinizer.yml
View file @
ce439368
filter
:
filter
:
paths
:
[
src/*
]
paths
:
[
src/*
]
checks
:
checks
:
php
:
php
:
remove_extra_empty_lines
:
true
remove_extra_empty_lines
:
true
remove_php_closing_tag
:
true
remove_php_closing_tag
:
true
remove_trailing_whitespace
:
true
remove_trailing_whitespace
:
true
fix_use_statements
:
fix_use_statements
:
remove_unused
:
true
remove_unused
:
true
preserve_multiple
:
false
preserve_multiple
:
false
preserve_blanklines
:
true
preserve_blanklines
:
true
order_alphabetically
:
true
order_alphabetically
:
true
fix_php_opening_tag
:
true
fix_php_opening_tag
:
true
fix_linefeed
:
true
fix_linefeed
:
true
fix_line_ending
:
true
fix_line_ending
:
true
fix_identation_4spaces
:
true
fix_identation_4spaces
:
true
fix_doc_comments
:
true
fix_doc_comments
:
true
tools
:
tools
:
external_code_coverage
:
external_code_coverage
:
timeout
:
120
timeout
:
120
phpunit.xml.dist
View file @
ce439368
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
<phpunit
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://schema.phpunit.de/4.8/phpunit.xsd"
xsi:noNamespaceSchemaLocation=
"http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap=
"./tests/bootstrap.php"
bootstrap=
"./tests/bootstrap.php"
backupGlobals=
"false"
backupGlobals=
"false"
backupStaticAttributes=
"false"
backupStaticAttributes=
"false"
colors=
"true"
colors=
"true"
convertErrorsToExceptions=
"true"
convertErrorsToExceptions=
"true"
convertNoticesToExceptions=
"true"
convertNoticesToExceptions=
"true"
convertWarningsToExceptions=
"true"
convertWarningsToExceptions=
"true"
processIsolation=
"false"
processIsolation=
"false"
stopOnError=
"false"
stopOnError=
"false"
stopOnFailure=
"false"
stopOnFailure=
"false"
stopOnIncomplete=
"false"
stopOnIncomplete=
"false"
stopOnSkipped=
"false"
stopOnSkipped=
"false"
syntaxCheck=
"true"
syntaxCheck=
"true"
timeoutForLargeTests=
"60"
timeoutForLargeTests=
"60"
timeoutForMediumTests=
"10"
timeoutForMediumTests=
"10"
timeoutForSmallTests=
"1"
timeoutForSmallTests=
"1"
verbose=
"false"
verbose=
"false"
>
>
<php>
<php>
<ini
name=
"error_reporting"
value=
"-1"
/>
<ini
name=
"error_reporting"
value=
"-1"
/>
<const
name=
"PHPUNIT_TESTSUITE"
value=
"true"
/>
<const
name=
"PHPUNIT_TESTSUITE"
value=
"true"
/>
<const
name=
"PHPUNIT_DB_HOST"
value=
"127.0.0.1"
/>
<const
name=
"PHPUNIT_DB_HOST"
value=
"127.0.0.1"
/>
<const
name=
"PHPUNIT_DB_NAME"
value=
"telegrambot"
/>
<const
name=
"PHPUNIT_DB_NAME"
value=
"telegrambot"
/>
...
...
src/Commands/AdminCommands/DebugCommand.php
View file @
ce439368
...
@@ -47,10 +47,10 @@ class DebugCommand extends AdminCommand
...
@@ -47,10 +47,10 @@ class DebugCommand extends AdminCommand
*/
*/
public
function
execute
()
public
function
execute
()
{
{
$pdo
=
DB
::
getPdo
();
$pdo
=
DB
::
getPdo
();
$message
=
$this
->
getMessage
();
$message
=
$this
->
getMessage
();
$chat
=
$message
->
getChat
();
$chat
=
$message
->
getChat
();
$text
=
strtolower
(
$message
->
getText
(
true
));
$text
=
strtolower
(
$message
->
getText
(
true
));
$data
=
[
'chat_id'
=>
$chat
->
getId
()];
$data
=
[
'chat_id'
=>
$chat
->
getId
()];
...
@@ -80,7 +80,7 @@ class DebugCommand extends AdminCommand
...
@@ -80,7 +80,7 @@ class DebugCommand extends AdminCommand
$debug_info
[]
=
sprintf
(
'*Maximum PHP script execution time:* `%d seconds`'
,
ini_get
(
'max_execution_time'
));
$debug_info
[]
=
sprintf
(
'*Maximum PHP script execution time:* `%d seconds`'
,
ini_get
(
'max_execution_time'
));
$mysql_version
=
$pdo
?
$pdo
->
query
(
'SELECT VERSION() AS version'
)
->
fetchColumn
()
:
null
;
$mysql_version
=
$pdo
?
$pdo
->
query
(
'SELECT VERSION() AS version'
)
->
fetchColumn
()
:
null
;
$debug_info
[]
=
sprintf
(
'*MySQL version:* `%s`'
,
$mysql_version
?:
'disabled'
);
$debug_info
[]
=
sprintf
(
'*MySQL version:* `%s`'
,
$mysql_version
?:
'disabled'
);
$debug_info
[]
=
sprintf
(
'*Operating System:* `%s`'
,
php_uname
());
$debug_info
[]
=
sprintf
(
'*Operating System:* `%s`'
,
php_uname
());
...
@@ -88,7 +88,7 @@ class DebugCommand extends AdminCommand
...
@@ -88,7 +88,7 @@ class DebugCommand extends AdminCommand
$debug_info
[]
=
sprintf
(
'*Web Server:* `%s`'
,
$_SERVER
[
'SERVER_SOFTWARE'
]);
$debug_info
[]
=
sprintf
(
'*Web Server:* `%s`'
,
$_SERVER
[
'SERVER_SOFTWARE'
]);
}
}
if
(
function_exists
(
'curl_init'
))
{
if
(
function_exists
(
'curl_init'
))
{
$curlversion
=
curl_version
();
$curlversion
=
curl_version
();
$debug_info
[]
=
sprintf
(
'*curl version:* `%1$s; %2$s`'
,
$curlversion
[
'version'
],
$curlversion
[
'ssl_version'
]);
$debug_info
[]
=
sprintf
(
'*curl version:* `%1$s; %2$s`'
,
$curlversion
[
'version'
],
$curlversion
[
'ssl_version'
]);
}
}
...
@@ -105,8 +105,8 @@ class DebugCommand extends AdminCommand
...
@@ -105,8 +105,8 @@ class DebugCommand extends AdminCommand
}
}
$webhook_info_result_str
=
json_encode
(
$webhook_info_result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
);
$webhook_info_result_str
=
json_encode
(
$webhook_info_result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
);
$debug_info
[]
=
$webhook_info_title
;
$debug_info
[]
=
$webhook_info_title
;
$debug_info
[]
=
sprintf
(
$debug_info
[]
=
sprintf
(
'```'
.
PHP_EOL
.
'%s```'
,
'```'
.
PHP_EOL
.
'%s```'
,
$webhook_info_result_str
$webhook_info_result_str
);
);
...
@@ -116,7 +116,7 @@ class DebugCommand extends AdminCommand
...
@@ -116,7 +116,7 @@ class DebugCommand extends AdminCommand
}
}
$data
[
'parse_mode'
]
=
'Markdown'
;
$data
[
'parse_mode'
]
=
'Markdown'
;
$data
[
'text'
]
=
implode
(
PHP_EOL
,
$debug_info
);
$data
[
'text'
]
=
implode
(
PHP_EOL
,
$debug_info
);
return
Request
::
sendMessage
(
$data
);
return
Request
::
sendMessage
(
$data
);
}
}
...
...
src/Commands/SystemCommands/GenericCommand.php
View file @
ce439368
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
/**
* Generic command
* Generic command
...
...
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
ce439368
...
@@ -10,9 +10,9 @@
...
@@ -10,9 +10,9 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Conversation
;
use
Longman\TelegramBot\Conversation
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
/**
* Generic message command
* Generic message command
...
...
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
ce439368
...
@@ -11,8 +11,6 @@
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Request
;
/**
/**
...
...
src/Commands/SystemCommands/StartCommand.php
View file @
ce439368
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
/**
* Start command
* Start command
...
...
src/Entities/Keyboard.php
View file @
ce439368
...
@@ -179,7 +179,7 @@ class Keyboard extends Entity
...
@@ -179,7 +179,7 @@ class Keyboard extends Entity
protected
function
validate
()
protected
function
validate
()
{
{
$keyboard_type
=
$this
->
getKeyboardType
();
$keyboard_type
=
$this
->
getKeyboardType
();
$keyboard
=
$this
->
getProperty
(
$keyboard_type
);
$keyboard
=
$this
->
getProperty
(
$keyboard_type
);
if
(
$keyboard
!==
null
)
{
if
(
$keyboard
!==
null
)
{
if
(
!
is_array
(
$keyboard
))
{
if
(
!
is_array
(
$keyboard
))
{
...
...
src/Telegram.php
View file @
ce439368
...
@@ -442,7 +442,7 @@ class Telegram
...
@@ -442,7 +442,7 @@ class Telegram
*/
*/
public
function
processUpdate
(
Update
$update
)
public
function
processUpdate
(
Update
$update
)
{
{
$this
->
update
=
$update
;
$this
->
update
=
$update
;
$this
->
last_update_id
=
$update
->
getUpdateId
();
$this
->
last_update_id
=
$update
->
getUpdateId
();
//Load admin commands
//Load admin commands
...
@@ -877,7 +877,7 @@ class Telegram
...
@@ -877,7 +877,7 @@ class Telegram
/**
/**
* Enable requests limiter
* Enable requests limiter
*
*
* @param
array $options
* @param array $options
*
*
* @return \Longman\TelegramBot\Telegram
* @return \Longman\TelegramBot\Telegram
* @throws TelegramException
* @throws TelegramException
...
@@ -902,7 +902,7 @@ class Telegram
...
@@ -902,7 +902,7 @@ class Telegram
throw
new
TelegramException
(
'No command(s) provided!'
);
throw
new
TelegramException
(
'No command(s) provided!'
);
}
}
$this
->
run_commands
=
true
;
$this
->
run_commands
=
true
;
$result
=
Request
::
getMe
();
$result
=
Request
::
getMe
();
...
...
tests/unit/ConversationTest.php
View file @
ce439368
...
@@ -53,7 +53,7 @@ class ConversationTest extends TestCase
...
@@ -53,7 +53,7 @@ class ConversationTest extends TestCase
public
function
testConversationThatExistsPropertiesSetCorrectly
()
public
function
testConversationThatExistsPropertiesSetCorrectly
()
{
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertAttributeEquals
(
$info
[
'user_id'
],
'user_id'
,
$conversation
);
$this
->
assertAttributeEquals
(
$info
[
'user_id'
],
'user_id'
,
$conversation
);
$this
->
assertAttributeEquals
(
$info
[
'chat_id'
],
'chat_id'
,
$conversation
);
$this
->
assertAttributeEquals
(
$info
[
'chat_id'
],
'chat_id'
,
$conversation
);
...
@@ -85,7 +85,7 @@ class ConversationTest extends TestCase
...
@@ -85,7 +85,7 @@ class ConversationTest extends TestCase
public
function
testNewConversationThatWillExistWithCommand
()
public
function
testNewConversationThatWillExistWithCommand
()
{
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$this
->
assertTrue
(
$conversation
->
exists
());
$this
->
assertEquals
(
'command'
,
$conversation
->
getCommand
());
$this
->
assertEquals
(
'command'
,
$conversation
->
getCommand
());
...
@@ -93,7 +93,7 @@ class ConversationTest extends TestCase
...
@@ -93,7 +93,7 @@ class ConversationTest extends TestCase
public
function
testStopConversation
()
public
function
testStopConversation
()
{
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$this
->
assertTrue
(
$conversation
->
exists
());
$conversation
->
stop
();
$conversation
->
stop
();
...
@@ -104,7 +104,7 @@ class ConversationTest extends TestCase
...
@@ -104,7 +104,7 @@ class ConversationTest extends TestCase
public
function
testCancelConversation
()
public
function
testCancelConversation
()
{
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$this
->
assertTrue
(
$conversation
->
exists
());
$conversation
->
cancel
();
$conversation
->
cancel
();
...
@@ -115,8 +115,8 @@ class ConversationTest extends TestCase
...
@@ -115,8 +115,8 @@ class ConversationTest extends TestCase
public
function
testUpdateConversationNotes
()
public
function
testUpdateConversationNotes
()
{
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
->
notes
=
'newnote'
;
$conversation
->
notes
=
'newnote'
;
$conversation
->
update
();
$conversation
->
update
();
...
...
tests/unit/Entities/ServerResponseTest.php
View file @
ce439368
...
@@ -306,7 +306,7 @@ class ServerResponseTest extends TestCase
...
@@ -306,7 +306,7 @@ class ServerResponseTest extends TestCase
//... they are not finished...
//... they are not finished...
}
}
public
function
getStickerSet
()
public
function
getStickerSet
()
{
{
TestHelpers
::
setStaticProperty
(
Request
::
class
,
'current_action'
,
'getStickerSet'
);
TestHelpers
::
setStaticProperty
(
Request
::
class
,
'current_action'
,
'getStickerSet'
);
...
@@ -357,19 +357,19 @@ class ServerResponseTest extends TestCase
...
@@ -357,19 +357,19 @@ class ServerResponseTest extends TestCase
}
}
}'
;
}'
;
}
}
public
function
testGetStickerSet
()
public
function
testGetStickerSet
()
{
{
$result
=
$this
->
getStickerSet
();
$result
=
$this
->
getStickerSet
();
$server
=
new
ServerResponse
(
json_decode
(
$result
,
true
),
'testbot'
);
$server
=
new
ServerResponse
(
json_decode
(
$result
,
true
),
'testbot'
);
$server_result
=
$server
->
getResult
();
$server_result
=
$server
->
getResult
();
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\StickerSet'
,
$server_result
);
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\StickerSet'
,
$server_result
);
self
::
assertEquals
(
'stickerset_name'
,
$server_result
->
getName
());
self
::
assertEquals
(
'stickerset_name'
,
$server_result
->
getName
());
self
::
assertEquals
(
'Some name'
,
$server_result
->
getTitle
());
self
::
assertEquals
(
'Some name'
,
$server_result
->
getTitle
());
self
::
assertFalse
(
$server_result
->
getContainsMasks
());
self
::
assertFalse
(
$server_result
->
getContainsMasks
());
$stickers
=
$server_result
->
getStickers
();
$stickers
=
$server_result
->
getStickers
();
self
::
assertCount
(
4
,
$stickers
);
self
::
assertCount
(
4
,
$stickers
);
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\Sticker'
,
$stickers
[
0
]);
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\Sticker'
,
$stickers
[
0
]);
...
...
tests/unit/TestHelpers.php
View file @
ce439368
...
@@ -223,7 +223,7 @@ class TestHelpers
...
@@ -223,7 +223,7 @@ class TestHelpers
/**
/**
* Empty all tables for the passed database
* Empty all tables for the passed database
*
*
* @param
array $credentials
* @param array $credentials
*/
*/
public
static
function
emptyDb
(
array
$credentials
)
public
static
function
emptyDb
(
array
$credentials
)
{
{
...
...
utils/importFromLog.php
View file @
ce439368
<?php
<?php
require
__DIR__
.
'/../vendor/autoload.php'
;
require
__DIR__
.
'/../vendor/autoload.php'
;
$filename
=
'logfile.log'
;
$filename
=
'logfile.log'
;
$API_KEY
=
'random'
;
$API_KEY
=
'random'
;
$BOT_NAME
=
'bot_name'
;
$BOT_NAME
=
'bot_name'
;
define
(
'PHPUNIT_TESTSUITE'
,
'some value'
);
define
(
'PHPUNIT_TESTSUITE'
,
'some value'
);
$CREDENTIALS
=
array
(
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
)
;
$CREDENTIALS
=
[
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
]
;
$update
=
null
;
$update
=
null
;
try
{
try
{
...
...
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