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
ef95789a
Commit
ef95789a
authored
Oct 30, 2016
by
Monster3D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds new Unit test for Entities/Location
parent
ba352838
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
+120
-0
LocationTest.php
tests/unit/Entities/LocationTest.php
+120
-0
No files found.
tests/unit/Entities/LocationTest.php
0 → 100644
View file @
ef95789a
<?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\Location
;
use
Longman\TelegramBot\Exception\TelegramException
;
use
Longman\TelegramBot\Tests\Unit\TestHelpers
;
/**
* @package TelegramTest
* @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
LocationTest
extends
TestCase
{
/**
* lat, long data
*
* @var array
*
*/
public
$coordinates
;
/**
*
* Set Up
*
*/
public
function
setUp
()
{
$this
->
coordinates
=
[
'longitude'
=>
(
float
)
mt_rand
(
10
,
69
),
'latitude'
=>
(
float
)
mt_rand
(
10
,
48
)
];
}
/**
*
* TearDown
*
*/
public
function
tearDown
()
{
//pass
}
/**
*
* Testing base stage with data object creating
*
*/
public
function
testBaseStageLocation
()
{
$location
=
new
Location
(
$this
->
coordinates
);
$this
->
assertInstanceOf
(
'Longman\TelegramBot\Entities\Location'
,
$location
);
}
/**
*
* Testing getLongitude
*
*/
public
function
testGetLongitude
()
{
$location
=
new
Location
(
$this
->
coordinates
);
$long
=
$location
->
getLongitude
();
$this
->
assertInternalType
(
'float'
,
$long
);
$this
->
assertEquals
(
$this
->
coordinates
[
'longitude'
],
$long
);
}
/**
*
* Testing getLatitude
*
*/
public
function
testGetLatitude
()
{
$location
=
new
Location
(
$this
->
coordinates
);
$lat
=
$location
->
getLatitude
();
$this
->
assertInternalType
(
'float'
,
$lat
);
$this
->
assertEquals
(
$this
->
coordinates
[
'latitude'
],
$lat
);
}
/**
*
* Testing getLongitude without longitude
*
* @expectedException Longman\TelegramBot\Exception\TelegramException
*
*/
public
function
testGetLongitudeWithoutLongitude
()
{
unset
(
$this
->
coordinates
[
'longitude'
]);
new
Location
(
$this
->
coordinates
);
}
/**
*
* Testing getLongitude without latitude
*
* @expectedException Longman\TelegramBot\Exception\TelegramException
*
*/
public
function
testGetLongitudeWithoutLatitude
()
{
unset
(
$this
->
coordinates
[
'latitude'
]);
new
Location
(
$this
->
coordinates
);
}
}
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