Commit 2d32beca authored by Armando Lüscher's avatar Armando Lüscher

Fix a few base test classes.

parent f6cf49fe
<?php
/*
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
......@@ -7,7 +7,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests;
/*
* Set error reporting to the max level.
*/
......@@ -18,24 +20,22 @@ error_reporting(-1);
*/
date_default_timezone_set('UTC');
$autoloader = __DIR__ . '/../vendor/autoload.php';
$root = realpath(dirname(dirname(__FILE__)));
/**
/*
* Check that --dev composer installation was done
*/
if (!file_exists($root . '/vendor/autoload.php')) {
if (!file_exists($autoloader)) {
throw new \Exception(
'Please run "php composer.phar install --dev" in root directory '
. 'to setup unit test dependencies before running the tests'
);
}
// Include the Composer autoloader
$loader = require __DIR__ . '/../vendor/autoload.php';
//Include the Composer autoloader
require_once $autoloader;
/*
* Unset global variables that are no longer needed.
*/
unset($root, $loader);
unset($autoloader);
<?php
/*
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
......@@ -7,78 +7,83 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tests\Unit;
use \Longman\TelegramBot\Telegram;
use Longman\TelegramBot\Telegram;
/**
* @package TelegramTest
* @author Avtandil Kikabidze <akalongman@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
* @package TelegramTest
* @author Avtandil Kikabidze <akalongman@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 TelegramTest extends TestCase
{
/**
* @var \Longman\TelegramBot\Telegram
*/
private $telegram;
/**
* setUp
*/
protected function setUp()
{
$this->telegram = new Telegram('testapikey', 'testbotname');
}
/**
* @var \Longman\TelegramBot\Telegram
*/
private $telegram;
/**
* setUp
*/
protected function setUp()
{
$this->telegram = new Telegram('testapikey', 'testbotname');
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramException
*/
public function newInstanceWithoutParams() {
$telegram = new Telegram('testapikey', null);
$telegram = new Telegram(null, 'test');
public function newInstanceWithoutApiKeyParam()
{
new Telegram(null, 'testbotname');
}
/**
* @test
* @expectedException \Longman\TelegramBot\Exception\TelegramException
*/
public function getCommandsList() {
$commands = $this->telegram->getCommandsList();
$this->assertInternalType('array', $commands);
$this->assertNotCount(0, $commands);
public function newInstanceWithoutBotNameParam()
{
new Telegram('testapikey', null);
}
/**
* @test
*/
public function getCommandsClass() {
$command = $this->telegram->getCommandClass('help');
$this->assertInstanceOf('Longman\TelegramBot\Commands\HelpCommand', $command);
public function getApiKey()
{
$this->assertEquals('testapikey', $this->telegram->getApiKey());
}
/**
* @test
*/
public function getApiKey() {
$this->assertEquals('testapikey', $this->telegram->getApiKey());
public function getBotName()
{
$this->assertEquals('testbotname', $this->telegram->getBotName());
}
/**
* @test
*/
public function getBotName() {
$this->assertEquals('testbotname', $this->telegram->getBotName());
public function getCommandsList()
{
$commands = $this->telegram->getCommandsList();
$this->assertInternalType('array', $commands);
$this->assertNotCount(0, $commands);
}
/**
* @test
*/
public function getHelpCommandObject()
{
$command = $this->telegram->getCommandObject('help');
$this->assertInstanceOf('Longman\TelegramBot\Commands\UserCommands\HelpCommand', $command);
}
}
......@@ -12,5 +12,4 @@ class TestCase extends \PHPUnit_Framework_TestCase
);
}
}
}
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