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
7abd9661
Commit
7abd9661
authored
Oct 30, 2016
by
Monster3D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds new Unit test for Entities/File
parent
8747702a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
146 additions
and
0 deletions
+146
-0
FileTest.php
tests/unit/Entities/FileTest.php
+146
-0
No files found.
tests/unit/Entities/FileTest.php
0 → 100644
View file @
7abd9661
<?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\File
;
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
FileTest
extends
TestCase
{
/**
* lat, long data
*
* @var array
*
*/
public
$data
;
/**
*
* Set Up
*
*/
public
function
setUp
()
{
$this
->
data
=
[
'file_id'
=>
(
int
)
mt_rand
(
1
,
99
),
'file_size'
=>
(
int
)
mt_rand
(
100
,
99999
),
'file_path'
=>
'home'
.
DIRECTORY_SEPARATOR
.
'phpunit'
];
}
/**
*
* TearDown
*
*/
public
function
tearDown
()
{
//pass
}
/**
*
* Testing base stage with data object creating
*
*/
public
function
testBaseStageLocation
()
{
$file
=
new
File
(
$this
->
data
);
$this
->
assertInstanceOf
(
'Longman\TelegramBot\Entities\File'
,
$file
);
}
/**
*
* Testing getFileId
*
*/
public
function
testGetFileId
()
{
$file
=
new
File
(
$this
->
data
);
$id
=
$file
->
getFileId
();
$this
->
assertInternalType
(
'int'
,
$id
);
$this
->
assertEquals
(
$this
->
data
[
'file_id'
],
$id
);
}
/**
*
* Testing getFileSize
*
*/
public
function
testGetFileSize
()
{
$file
=
new
File
(
$this
->
data
);
$size
=
$file
->
getFileSize
();
$this
->
assertInternalType
(
'int'
,
$size
);
$this
->
assertEquals
(
$this
->
data
[
'file_size'
],
$size
);
}
/**
*
* Testing getFilePath
*
*/
public
function
testGetFilePath
()
{
$file
=
new
File
(
$this
->
data
);
$path
=
$file
->
getFilePath
();
$this
->
assertEquals
(
$this
->
data
[
'file_path'
],
$path
);
}
/**
*
* Testing without file id
*
* @expectedException Longman\TelegramBot\Exception\TelegramException
*
*/
public
function
testCreateInstanceWithoutFileId
()
{
unset
(
$this
->
data
[
'file_id'
]);
new
File
(
$this
->
data
);
}
/**
*
* Testing getFileSize without data
*
*/
public
function
testGetFileSizeWithoutData
()
{
unset
(
$this
->
data
[
'file_size'
]);
$file
=
new
File
(
$this
->
data
);
$id
=
$file
->
getFileSize
();
$this
->
assertNull
(
$id
);
}
/**
*
* Testing getFilePath without data
*
*/
public
function
testGetFilePathWithoutData
()
{
unset
(
$this
->
data
[
'file_path'
]);
$file
=
new
File
(
$this
->
data
);
$path
=
$file
->
getFilePath
();
$this
->
assertNull
(
$path
);
}
}
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