Display the list of assigned commands paths.

Add extra tests for getCommandsPaths method.
parent 1cca9d4f
......@@ -57,6 +57,13 @@ class DebugCommand extends AdminCommand
$debug_info[] = sprintf('*Download path:* `%s`', $this->telegram->getDownloadPath());
$debug_info[] = sprintf('*Upload path:* `%s`', $this->telegram->getUploadPath());
// Commands paths.
$debug_info[] = '*Commands paths:*';
$debug_info[] = sprintf(
'```' . PHP_EOL . '%s```',
json_encode($this->telegram->getCommandsPaths(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
$php_bit = '';
PHP_INT_SIZE === 4 && $php_bit = ' (32bit)';
PHP_INT_SIZE === 8 && $php_bit = ' (64bit)';
......
......@@ -619,6 +619,16 @@ class Telegram
return $this;
}
/**
* Return the list of commands paths
*
* @return array
*/
public function getCommandsPaths()
{
return $this->commands_paths;
}
/**
* Set custom upload path
*
......
......@@ -116,22 +116,30 @@ class TelegramTest extends TestCase
{
$tg = $this->telegram;
$this->assertAttributeCount(1, 'commands_paths', $tg);
$this->assertCount(1, $tg->getCommandsPaths());
$tg->addCommandsPath($this->custom_commands_paths[0]);
$this->assertAttributeCount(2, 'commands_paths', $tg);
$this->assertCount(2, $tg->getCommandsPaths());
$this->assertArraySubset(
[$this->custom_commands_paths[0]],
$tg->getCommandsPaths()
);
$tg->addCommandsPath('/invalid/path');
$this->assertAttributeCount(2, 'commands_paths', $tg);
$this->assertCount(2, $tg->getCommandsPaths());
$tg->addCommandsPaths([
$this->custom_commands_paths[1],
$this->custom_commands_paths[2],
]);
$this->assertAttributeCount(4, 'commands_paths', $tg);
$this->assertCount(4, $tg->getCommandsPaths());
$this->assertArraySubset(
array_reverse($this->custom_commands_paths),
$tg->getCommandsPaths()
);
$tg->addCommandsPath($this->custom_commands_paths[0]);
$this->assertAttributeCount(4, 'commands_paths', $tg);
$this->assertCount(4, $tg->getCommandsPaths());
}
public function testGetCommandsList()
......
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