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
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.{yml, yaml}]
indent_size = 2
.scrutinizer.yml
View file @
ce439368
filter
:
paths
:
[
src/*
]
paths
:
[
src/*
]
checks
:
php
:
remove_extra_empty_lines
:
true
remove_php_closing_tag
:
true
remove_trailing_whitespace
:
true
fix_use_statements
:
remove_unused
:
true
preserve_multiple
:
false
preserve_blanklines
:
true
order_alphabetically
:
true
fix_php_opening_tag
:
true
fix_linefeed
:
true
fix_line_ending
:
true
fix_identation_4spaces
:
true
fix_doc_comments
:
true
php
:
remove_extra_empty_lines
:
true
remove_php_closing_tag
:
true
remove_trailing_whitespace
:
true
fix_use_statements
:
remove_unused
:
true
preserve_multiple
:
false
preserve_blanklines
:
true
order_alphabetically
:
true
fix_php_opening_tag
:
true
fix_linefeed
:
true
fix_line_ending
:
true
fix_identation_4spaces
:
true
fix_doc_comments
:
true
tools
:
external_code_coverage
:
timeout
:
120
external_code_coverage
:
timeout
:
120
phpunit.xml.dist
View file @
ce439368
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap=
"./tests/bootstrap.php"
backupGlobals=
"false"
backupStaticAttributes=
"false"
colors=
"true"
convertErrorsToExceptions=
"true"
convertNoticesToExceptions=
"true"
convertWarningsToExceptions=
"true"
processIsolation=
"false"
stopOnError=
"false"
stopOnFailure=
"false"
stopOnIncomplete=
"false"
stopOnSkipped=
"false"
syntaxCheck=
"true"
timeoutForLargeTests=
"60"
timeoutForMediumTests=
"10"
timeoutForSmallTests=
"1"
verbose=
"false"
>
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap=
"./tests/bootstrap.php"
backupGlobals=
"false"
backupStaticAttributes=
"false"
colors=
"true"
convertErrorsToExceptions=
"true"
convertNoticesToExceptions=
"true"
convertWarningsToExceptions=
"true"
processIsolation=
"false"
stopOnError=
"false"
stopOnFailure=
"false"
stopOnIncomplete=
"false"
stopOnSkipped=
"false"
syntaxCheck=
"true"
timeoutForLargeTests=
"60"
timeoutForMediumTests=
"10"
timeoutForSmallTests=
"1"
verbose=
"false"
>
<php>
<ini
name=
"error_reporting"
value=
"-1"
/>
<ini
name=
"error_reporting"
value=
"-1"
/>
<const
name=
"PHPUNIT_TESTSUITE"
value=
"true"
/>
<const
name=
"PHPUNIT_DB_HOST"
value=
"127.0.0.1"
/>
<const
name=
"PHPUNIT_DB_NAME"
value=
"telegrambot"
/>
...
...
src/Commands/AdminCommands/DebugCommand.php
View file @
ce439368
...
...
@@ -47,10 +47,10 @@ class DebugCommand extends AdminCommand
*/
public
function
execute
()
{
$pdo
=
DB
::
getPdo
();
$pdo
=
DB
::
getPdo
();
$message
=
$this
->
getMessage
();
$chat
=
$message
->
getChat
();
$text
=
strtolower
(
$message
->
getText
(
true
));
$chat
=
$message
->
getChat
();
$text
=
strtolower
(
$message
->
getText
(
true
));
$data
=
[
'chat_id'
=>
$chat
->
getId
()];
...
...
@@ -80,7 +80,7 @@ class DebugCommand extends AdminCommand
$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
;
$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
());
...
...
@@ -88,7 +88,7 @@ class DebugCommand extends AdminCommand
$debug_info
[]
=
sprintf
(
'*Web Server:* `%s`'
,
$_SERVER
[
'SERVER_SOFTWARE'
]);
}
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'
]);
}
...
...
@@ -105,8 +105,8 @@ class DebugCommand extends AdminCommand
}
$webhook_info_result_str
=
json_encode
(
$webhook_info_result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
);
$debug_info
[]
=
$webhook_info_title
;
$debug_info
[]
=
sprintf
(
$debug_info
[]
=
$webhook_info_title
;
$debug_info
[]
=
sprintf
(
'```'
.
PHP_EOL
.
'%s```'
,
$webhook_info_result_str
);
...
...
@@ -116,7 +116,7 @@ class DebugCommand extends AdminCommand
}
$data
[
'parse_mode'
]
=
'Markdown'
;
$data
[
'text'
]
=
implode
(
PHP_EOL
,
$debug_info
);
$data
[
'text'
]
=
implode
(
PHP_EOL
,
$debug_info
);
return
Request
::
sendMessage
(
$data
);
}
...
...
src/Commands/SystemCommands/GenericCommand.php
View file @
ce439368
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* Generic command
...
...
src/Commands/SystemCommands/GenericmessageCommand.php
View file @
ce439368
...
...
@@ -10,9 +10,9 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Conversation
;
use
Longman\TelegramBot\Request
;
use
Longman\TelegramBot\Commands\SystemCommand
;
/**
* Generic message command
...
...
src/Commands/SystemCommands/InlinequeryCommand.php
View file @
ce439368
...
...
@@ -11,8 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle
;
use
Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent
;
use
Longman\TelegramBot\Request
;
/**
...
...
src/Commands/SystemCommands/StartCommand.php
View file @
ce439368
...
...
@@ -11,7 +11,6 @@
namespace
Longman\TelegramBot\Commands\SystemCommands
;
use
Longman\TelegramBot\Commands\SystemCommand
;
use
Longman\TelegramBot\Request
;
/**
* Start command
...
...
src/Entities/Keyboard.php
View file @
ce439368
...
...
@@ -179,7 +179,7 @@ class Keyboard extends Entity
protected
function
validate
()
{
$keyboard_type
=
$this
->
getKeyboardType
();
$keyboard
=
$this
->
getProperty
(
$keyboard_type
);
$keyboard
=
$this
->
getProperty
(
$keyboard_type
);
if
(
$keyboard
!==
null
)
{
if
(
!
is_array
(
$keyboard
))
{
...
...
src/Telegram.php
View file @
ce439368
...
...
@@ -442,7 +442,7 @@ class Telegram
*/
public
function
processUpdate
(
Update
$update
)
{
$this
->
update
=
$update
;
$this
->
update
=
$update
;
$this
->
last_update_id
=
$update
->
getUpdateId
();
//Load admin commands
...
...
@@ -877,7 +877,7 @@ class Telegram
/**
* Enable requests limiter
*
* @param
array $options
* @param array $options
*
* @return \Longman\TelegramBot\Telegram
* @throws TelegramException
...
...
@@ -902,7 +902,7 @@ class Telegram
throw
new
TelegramException
(
'No command(s) provided!'
);
}
$this
->
run_commands
=
true
;
$this
->
run_commands
=
true
;
$result
=
Request
::
getMe
();
...
...
tests/unit/ConversationTest.php
View file @
ce439368
...
...
@@ -53,7 +53,7 @@ class ConversationTest extends TestCase
public
function
testConversationThatExistsPropertiesSetCorrectly
()
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertAttributeEquals
(
$info
[
'user_id'
],
'user_id'
,
$conversation
);
$this
->
assertAttributeEquals
(
$info
[
'chat_id'
],
'chat_id'
,
$conversation
);
...
...
@@ -85,7 +85,7 @@ class ConversationTest extends TestCase
public
function
testNewConversationThatWillExistWithCommand
()
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$this
->
assertEquals
(
'command'
,
$conversation
->
getCommand
());
...
...
@@ -93,7 +93,7 @@ class ConversationTest extends TestCase
public
function
testStopConversation
()
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$conversation
->
stop
();
...
...
@@ -104,7 +104,7 @@ class ConversationTest extends TestCase
public
function
testCancelConversation
()
{
$info
=
TestHelpers
::
startFakeConversation
();
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$this
->
assertTrue
(
$conversation
->
exists
());
$conversation
->
cancel
();
...
...
@@ -115,8 +115,8 @@ class ConversationTest extends TestCase
public
function
testUpdateConversationNotes
()
{
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$info
=
TestHelpers
::
startFakeConversation
();
$conversation
=
new
Conversation
(
$info
[
'user_id'
],
$info
[
'chat_id'
],
'command'
);
$conversation
->
notes
=
'newnote'
;
$conversation
->
update
();
...
...
tests/unit/Entities/ServerResponseTest.php
View file @
ce439368
...
...
@@ -306,7 +306,7 @@ class ServerResponseTest extends TestCase
//... they are not finished...
}
public
function
getStickerSet
()
{
TestHelpers
::
setStaticProperty
(
Request
::
class
,
'current_action'
,
'getStickerSet'
);
...
...
@@ -357,19 +357,19 @@ class ServerResponseTest extends TestCase
}
}'
;
}
public
function
testGetStickerSet
()
{
$result
=
$this
->
getStickerSet
();
$server
=
new
ServerResponse
(
json_decode
(
$result
,
true
),
'testbot'
);
$server_result
=
$server
->
getResult
();
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\StickerSet'
,
$server_result
);
self
::
assertEquals
(
'stickerset_name'
,
$server_result
->
getName
());
self
::
assertEquals
(
'Some name'
,
$server_result
->
getTitle
());
self
::
assertFalse
(
$server_result
->
getContainsMasks
());
$stickers
=
$server_result
->
getStickers
();
self
::
assertCount
(
4
,
$stickers
);
self
::
assertInstanceOf
(
'\Longman\TelegramBot\Entities\Sticker'
,
$stickers
[
0
]);
...
...
tests/unit/TestHelpers.php
View file @
ce439368
...
...
@@ -223,7 +223,7 @@ class TestHelpers
/**
* Empty all tables for the passed database
*
* @param
array $credentials
* @param array $credentials
*/
public
static
function
emptyDb
(
array
$credentials
)
{
...
...
utils/importFromLog.php
View file @
ce439368
<?php
require
__DIR__
.
'/../vendor/autoload.php'
;
$filename
=
'logfile.log'
;
$API_KEY
=
'random'
;
$filename
=
'logfile.log'
;
$API_KEY
=
'random'
;
$BOT_NAME
=
'bot_name'
;
define
(
'PHPUNIT_TESTSUITE'
,
'some value'
);
$CREDENTIALS
=
array
(
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
)
;
$CREDENTIALS
=
[
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
]
;
$update
=
null
;
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