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