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
68b75c1b
Commit
68b75c1b
authored
Oct 02, 2016
by
Monster3D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for unit testing class Entitiel/User
parent
1e35c4da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
0 deletions
+142
-0
UserTest.php
tests/unit/Entities/UserTest.php
+142
-0
No files found.
tests/unit/Entities/UserTest.php
0 → 100644
View file @
68b75c1b
<?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
;
use
Longman\TelegramBot\Entities\User
;
use
Longman\TelegramBot\Exception\TelegramException
;
/**
* @package UserTest
* @author Baev Nikolay <gametester3d@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
UserTest
extends
TestCase
{
/**
* setUp
*
*/
public
function
setUp
()
{
//void
}
/**
* tearDown
*
*/
public
function
tearDown
()
{
//void
}
/**
* Test base stage
*
*/
public
function
testStageBase
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
)]);
$this
->
assertInstanceOf
(
'Longman\TelegramBot\Entities\User'
,
$user
);
}
/**
* Test sage without param user id
*
* @expectedException Longman\TelegramBot\Exception\TelegramException
*
*/
public
function
testStageWithoutId
()
{
new
User
([]);
}
/**
* Test stage get user id
*
*/
public
function
testGetId
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
)]);
$result
=
$user
->
getId
();
$this
->
assertGreaterThan
(
0
,
$result
);
}
/**
* Test stage get first name
*
*/
public
function
testGetFirstName
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'first_name'
=>
'name_phpunit'
]);
$result
=
$user
->
getFirstName
();
$this
->
assertEquals
(
'name_phpunit'
,
$result
);
}
/**
* Test stage get last name
*
*/
public
function
testGetLastName
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'last_name'
=>
'name_phpunit'
]);
$result
=
$user
->
getLastName
();
$this
->
assertEquals
(
'name_phpunit'
,
$result
);
}
/**
* Test stage get username
*
*/
public
function
testGetUsername
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'username'
=>
'name_phpunit'
]);
$result
=
$user
->
getUsername
();
$this
->
assertEquals
(
'name_phpunit'
,
$result
);
}
/**
* Test stage mention user
*
*/
public
function
testTryMention
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'username'
=>
'name_phpunit'
]);
$result
=
$user
->
tryMention
();
$this
->
assertRegExp
(
'/^\@.*/'
,
$result
);
}
/**
* Test stage mention user without param username
*
*/
public
function
testTryMentionWithoutUsernameStageOne
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'first_name'
=>
'name_phpunit'
]);
$result
=
$user
->
tryMention
();
$this
->
assertEquals
(
'name_phpunit'
,
$result
);
}
/**
* Test stage mention user without username but with last and first name
*
*/
public
function
testTryMentionWithoutUsernameStageTwo
()
{
$user
=
new
User
([
'id'
=>
mt_rand
(
1
,
99
),
'first_name'
=>
'name_phpunit'
,
'last_name'
=>
'name_phpunit'
]);
$result
=
$user
->
tryMention
();
$this
->
assertRegExp
(
'/^.*\s{1}.*$/'
,
$result
);
}
}
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