Skip to content

Commit 1e302a8

Browse files
committed
Restructure tests, moving them into a separate folder and namespace.
1 parent 743a5a5 commit 1e302a8

File tree

6 files changed

+36
-31
lines changed

6 files changed

+36
-31
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"autoload-dev": {
3030
"psr-4": {
31-
"NPM\\TelegramBotManager\\": "tests"
31+
"NPM\\TelegramBotManager\\Tests\\": "tests/TelegramBotManager/Tests"
3232
}
3333
},
3434
"require-dev": {

composer.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ActionTest.php renamed to tests/TelegramBotManager/Tests/ActionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace NPM\TelegramBotManager;
11+
namespace NPM\TelegramBotManager\Tests;
12+
13+
use NPM\TelegramBotManager\Action;
1214

1315
class ActionTest extends \PHPUnit_Framework_TestCase
1416
{

tests/BotManagerTest.php renamed to tests/TelegramBotManager/Tests/BotManagerTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace NPM\TelegramBotManager;
11+
namespace NPM\TelegramBotManager\Tests;
1212

1313
use Longman\TelegramBot\Telegram;
1414
use Longman\TelegramBot\TelegramLog;
15+
use NPM\TelegramBotManager\BotManager;
1516

1617
/**
1718
* Class BotManagerTest.php
@@ -22,9 +23,14 @@
2223
*/
2324
class BotManagerTest extends \PHPUnit_Framework_TestCase
2425
{
25-
public function setUp()
26+
/**
27+
* @var array Live params for testing with live bot (get set in BotManagerTest->setUp()).
28+
*/
29+
public static $live_params = [];
30+
31+
public static function setUpBeforeClass()
2632
{
27-
ParamsTest::$live_params = [
33+
self::$live_params = [
2834
'api_key' => getenv('API_KEY'),
2935
'botname' => getenv('BOTNAME'),
3036
'secret' => 'super-secret',
@@ -181,16 +187,16 @@ public function testValidateAndSetWebhookSuccess()
181187

182188
public function testValidateAndSetWebhookSuccessLiveBot()
183189
{
184-
$botManager = new BotManager(array_merge(ParamsTest::$live_params, [
190+
$botManager = new BotManager(array_merge(self::$live_params, [
185191
'webhook' => 'https://example.com/hook.php',
186192
]));
187193

188194
TestHelpers::setObjectProperty(
189195
$botManager,
190196
'telegram',
191197
new Telegram(
192-
ParamsTest::$live_params['api_key'],
193-
ParamsTest::$live_params['botname']
198+
self::$live_params['api_key'],
199+
self::$live_params['botname']
194200
)
195201
);
196202

@@ -220,7 +226,7 @@ public function testValidateAndSetWebhookSuccessLiveBot()
220226
public function testUnsetWebhookViaRunLiveBot()
221227
{
222228
$_GET = ['a' => 'unset'];
223-
$botManager = new BotManager(array_merge(ParamsTest::$live_params, [
229+
$botManager = new BotManager(array_merge(self::$live_params, [
224230
'webhook' => 'https://example.com/hook.php',
225231
]));
226232
$output = $botManager->run()->getOutput();
@@ -330,7 +336,7 @@ public function testGetOutput()
330336

331337
public function testGetUpdatesLiveBot()
332338
{
333-
$botManager = new BotManager(ParamsTest::$live_params);
339+
$botManager = new BotManager(self::$live_params);
334340
$output = $botManager->run()->getOutput();
335341
self::assertContains('Updates processed: 0', $output);
336342
}
@@ -342,7 +348,7 @@ public function testGetUpdatesLoopLiveBot()
342348

343349
// Looping for 5 seconds should be enough to get a result.
344350
$_GET = ['l' => 5];
345-
$botManager = new BotManager(ParamsTest::$live_params);
351+
$botManager = new BotManager(self::$live_params);
346352
$output = $botManager->run()->getOutput();
347353
self::assertContains('Looping getUpdates until', $output);
348354
self::assertContains('Updates processed: 0', $output);

tests/ParamsTest.php renamed to tests/TelegramBotManager/Tests/ParamsTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace NPM\TelegramBotManager;
11+
namespace NPM\TelegramBotManager\Tests;
12+
13+
use NPM\TelegramBotManager\Params;
1214

1315
class ParamsTest extends \PHPUnit_Framework_TestCase
1416
{
15-
/**
16-
* @var array Live params for testing with live bot (get set in BotManagerTest->setUp()).
17-
*/
18-
public static $live_params = [];
19-
2017
/**
2118
* @var array Demo vital parameters.
2219
*/

tests/TestHelpers.php renamed to tests/TelegramBotManager/Tests/TestHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace NPM\TelegramBotManager;
11+
namespace NPM\TelegramBotManager\Tests;
1212

1313
class TestHelpers
1414
{

0 commit comments

Comments
 (0)