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
2d32beca
Commit
2d32beca
authored
Feb 20, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a few base test classes.
parent
f6cf49fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
50 deletions
+54
-50
Bootstrap.php
tests/Bootstrap.php
+9
-9
TelegramTest.php
tests/Unit/TelegramTest.php
+45
-40
TestCase.php
tests/Unit/TestCase.php
+0
-1
No files found.
tests/Bootstrap.php
View file @
2d32beca
<?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
(
$
auto
loader
);
tests/Unit/TelegramTest.php
View file @
2d32beca
<?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
newInstanceWithout
Params
()
{
$telegram
=
new
Telegram
(
'testapikey'
,
null
);
$telegram
=
new
Telegram
(
null
,
'test
'
);
public
function
newInstanceWithout
ApiKeyParam
()
{
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
get
CommandsClass
()
{
$command
=
$this
->
telegram
->
getCommandClass
(
'help'
);
$this
->
assertInstanceOf
(
'Longman\TelegramBot\Commands\HelpCommand'
,
$command
);
public
function
get
ApiKey
()
{
$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
);
}
}
tests/Unit/TestCase.php
View file @
2d32beca
...
...
@@ -12,5 +12,4 @@ class TestCase extends \PHPUnit_Framework_TestCase
);
}
}
}
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