Commit 7abd9661 authored by Monster3D's avatar Monster3D

Adds new Unit test for Entities/File

parent 8747702a
<?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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment