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
a4ea86d6
Unverified
Commit
a4ea86d6
authored
Oct 11, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Message tests and add initial ones for getType.
parent
27cc9e9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
47 deletions
+55
-47
MessageTest.php
tests/unit/Entities/MessageTest.php
+55
-47
No files found.
tests/unit/Entities/MessageTest.php
View file @
a4ea86d6
...
...
@@ -19,66 +19,74 @@ namespace Longman\TelegramBot\Tests\Unit;
*/
class
MessageTest
extends
TestCase
{
/**
* @var \Longman\TelegramBot\Entities\Message
*/
private
$message
;
public
function
testTextAndCommandRecognise
()
{
public
function
testTextAndCommandRecognise
()
{
// /command
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help'
]);
$this
->
assertEquals
(
'/help'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
'/help'
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
''
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help'
]);
self
::
assertEquals
(
'/help'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
'/help'
,
$
message
->
getText
());
self
::
assertEquals
(
''
,
$
message
->
getText
(
true
));
// text
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'some text'
]);
$this
->
assertEquals
(
''
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
''
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
'some text'
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
'some text'
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'some text'
]);
self
::
assertEquals
(
''
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
''
,
$
message
->
getCommand
());
self
::
assertEquals
(
'some text'
,
$
message
->
getText
());
self
::
assertEquals
(
'some text'
,
$
message
->
getText
(
true
));
// /command@bot
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help@testbot'
]);
$this
->
assertEquals
(
'/help@testbot'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
'/help@testbot'
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
''
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help@testbot'
]);
self
::
assertEquals
(
'/help@testbot'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
'/help@testbot'
,
$
message
->
getText
());
self
::
assertEquals
(
''
,
$
message
->
getText
(
true
));
// /commmad text
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help some text'
]);
$this
->
assertEquals
(
'/help'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
'/help some text'
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
'some text'
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help some text'
]);
self
::
assertEquals
(
'/help'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
'/help some text'
,
$
message
->
getText
());
self
::
assertEquals
(
'some text'
,
$
message
->
getText
(
true
));
// /command@bot some text
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help@testbot some text'
]);
$this
->
assertEquals
(
'/help@testbot'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
'/help@testbot some text'
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
'some text'
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help@testbot some text'
]);
self
::
assertEquals
(
'/help@testbot'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
'/help@testbot some text'
,
$
message
->
getText
());
self
::
assertEquals
(
'some text'
,
$
message
->
getText
(
true
));
// /commmad\n text
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help
\n
some text"
]);
$this
->
assertEquals
(
'/help'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
"/help
\n
some text"
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
' some text'
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help
\n
some text"
]);
self
::
assertEquals
(
'/help'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
"/help
\n
some text"
,
$
message
->
getText
());
self
::
assertEquals
(
' some text'
,
$
message
->
getText
(
true
));
// /command@bot\nsome text
$
this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help@testbot
\n
some text"
]);
$this
->
assertEquals
(
'/help@testbot'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
"/help@testbot
\n
some text"
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
'some text'
,
$this
->
message
->
getText
(
true
));
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help@testbot
\n
some text"
]);
self
::
assertEquals
(
'/help@testbot'
,
$
message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$
message
->
getCommand
());
self
::
assertEquals
(
"/help@testbot
\n
some text"
,
$
message
->
getText
());
self
::
assertEquals
(
'some text'
,
$
message
->
getText
(
true
));
// /command@bot \nsome text
$this
->
message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help@testbot
\n
some text"
]);
$this
->
assertEquals
(
'/help@testbot'
,
$this
->
message
->
getFullCommand
());
$this
->
assertEquals
(
'help'
,
$this
->
message
->
getCommand
());
$this
->
assertEquals
(
"/help@testbot
\n
some text"
,
$this
->
message
->
getText
());
$this
->
assertEquals
(
"
\n
some text"
,
$this
->
message
->
getText
(
true
));
}
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
"/help@testbot
\n
some text"
]);
self
::
assertEquals
(
'/help@testbot'
,
$message
->
getFullCommand
());
self
::
assertEquals
(
'help'
,
$message
->
getCommand
());
self
::
assertEquals
(
"/help@testbot
\n
some text"
,
$message
->
getText
());
self
::
assertEquals
(
"
\n
some text"
,
$message
->
getText
(
true
));
}
public
function
testGetType
()
{
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
null
]);
self
::
assertSame
(
'message'
,
$message
->
getType
());
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'/help'
]);
self
::
assertSame
(
'command'
,
$message
->
getType
());
$message
=
TestHelpers
::
getFakeMessageObject
([
'text'
=>
'some text'
]);
self
::
assertSame
(
'text'
,
$message
->
getType
());
}
}
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