Rename BlockedServers to ServerBlock

This commit is contained in:
Philipp Holzer 2019-04-20 16:40:27 +02:00
parent f05f02409e
commit 8660f6d86f
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
3 changed files with 48 additions and 48 deletions

View file

@ -13,34 +13,12 @@ class Console extends \Asika\SimpleConsole\Console
protected $helpOptions = []; protected $helpOptions = [];
protected $customHelpOptions = ['h', 'help', '?']; protected $customHelpOptions = ['h', 'help', '?'];
protected $subConsoles = [
'blockedservers' => __NAMESPACE__ . '\Console\BlockedServers',
'cache' => __NAMESPACE__ . '\Console\Cache',
'config' => __NAMESPACE__ . '\Console\Config',
'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
'extract' => __NAMESPACE__ . '\Console\Extract',
'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
'typo' => __NAMESPACE__ . '\Console\Typo',
'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
'storage' => __NAMESPACE__ . '\Console\Storage',
];
protected function getHelp() protected function getHelp()
{ {
$help = <<<HELP $help = <<<HELP
Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v] Usage: bin/console [--version] [-h|--help|-?] <command> [<args>] [-v]
Commands: Commands:
blockedservers Manage blocked servers
cache Manage node cache cache Manage node cache
config Edit site config config Edit site config
createdoxygen Generate Doxygen headers createdoxygen Generate Doxygen headers
@ -58,6 +36,7 @@ Commands:
po2php Generate a strings.php file from a messages.po file po2php Generate a strings.php file from a messages.po file
typo Checks for parse errors in Friendica files typo Checks for parse errors in Friendica files
postupdate Execute pending post update scripts (can last days) postupdate Execute pending post update scripts (can last days)
serverblock Manage blocked servers
storage Manage storage backend storage Manage storage backend
Options: Options:
@ -67,6 +46,27 @@ HELP;
return $help; return $help;
} }
protected $subConsoles = [
'cache' => __NAMESPACE__ . '\Console\Cache',
'config' => __NAMESPACE__ . '\Console\Config',
'createdoxygen' => __NAMESPACE__ . '\Console\CreateDoxygen',
'docbloxerrorchecker' => __NAMESPACE__ . '\Console\DocBloxErrorChecker',
'dbstructure' => __NAMESPACE__ . '\Console\DatabaseStructure',
'extract' => __NAMESPACE__ . '\Console\Extract',
'globalcommunityblock' => __NAMESPACE__ . '\Console\GlobalCommunityBlock',
'globalcommunitysilence' => __NAMESPACE__ . '\Console\GlobalCommunitySilence',
'archivecontact' => __NAMESPACE__ . '\Console\ArchiveContact',
'autoinstall' => __NAMESPACE__ . '\Console\AutomaticInstallation',
'maintenance' => __NAMESPACE__ . '\Console\Maintenance',
'newpassword' => __NAMESPACE__ . '\Console\NewPassword',
'php2po' => __NAMESPACE__ . '\Console\PhpToPo',
'po2php' => __NAMESPACE__ . '\Console\PoToPhp',
'typo' => __NAMESPACE__ . '\Console\Typo',
'postupdate' => __NAMESPACE__ . '\Console\PostUpdate',
'serverblock' => __NAMESPACE__ . '\Console\ServerBlock',
'storage' => __NAMESPACE__ . '\Console\Storage',
];
protected function doExecute() protected function doExecute()
{ {
if ($this->getOption('v')) { if ($this->getOption('v')) {

View file

@ -14,7 +14,7 @@ use Friendica\Core\Config\Configuration;
* With this tool, you can list the current blocked servers * With this tool, you can list the current blocked servers
* or you can add / remove a blocked server from the list * or you can add / remove a blocked server from the list
*/ */
class BlockedServers extends Console class ServerBlock extends Console
{ {
const DEFAULT_REASON = 'blocked'; const DEFAULT_REASON = 'blocked';
@ -23,11 +23,11 @@ class BlockedServers extends Console
protected function getHelp() protected function getHelp()
{ {
$help = <<<HELP $help = <<<HELP
console blockedservers - Manage blocked servers console serverblock - Manage blocked servers
Usage Usage
bin/console blockedservers [-h|--help|-?] [-v] bin/console serverblock [-h|--help|-?] [-v]
bin/console blockedservers add <server> <reason> [-h|--help|-?] [-v] bin/console serverblock add <server> <reason> [-h|--help|-?] [-v]
bin/console blockedservers remove <server> [-h|--help|-?] [-v] bin/console serverblock remove <server> [-h|--help|-?] [-v]
Description Description
With this tool, you can list the current blocked servers With this tool, you can list the current blocked servers

View file

@ -2,13 +2,13 @@
namespace Friendica\Test\src\Core\Console; namespace Friendica\Test\src\Core\Console;
use Friendica\Core\Console\BlockedServers; use Friendica\Core\Console\ServerBlock;
/** /**
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
* @preserveGlobalState disabled * @preserveGlobalState disabled
*/ */
class BlockedServersConsoleTest extends ConsoleTest class ServerBlockConsoleTest extends ConsoleTest
{ {
protected $defaultBlockList = [ protected $defaultBlockList = [
[ [
@ -39,7 +39,7 @@ class BlockedServersConsoleTest extends ConsoleTest
->andReturn($this->defaultBlockList) ->andReturn($this->defaultBlockList)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
$output = <<<CONS $output = <<<CONS
@ -79,7 +79,7 @@ CONS;
->andReturn(true) ->andReturn(true)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'add'); $console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now'); $console->setArgument(1, 'testme.now');
$console->setArgument(2, 'I like it!'); $console->setArgument(2, 'I like it!');
@ -102,7 +102,7 @@ CONS;
$newBlockList = $this->defaultBlockList; $newBlockList = $this->defaultBlockList;
$newBlockList[] = [ $newBlockList[] = [
'domain' => 'testme.now', 'domain' => 'testme.now',
'reason' => BlockedServers::DEFAULT_REASON, 'reason' => ServerBlock::DEFAULT_REASON,
]; ];
$this->configMock $this->configMock
@ -111,12 +111,12 @@ CONS;
->andReturn(true) ->andReturn(true)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'add'); $console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now'); $console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
$this->assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'' . BlockedServers::DEFAULT_REASON . '\')' . PHP_EOL, $txt); $this->assertEquals('The domain \'testme.now\' is now blocked. (Reason: \'' . ServerBlock::DEFAULT_REASON . '\')' . PHP_EOL, $txt);
} }
/** /**
@ -147,7 +147,7 @@ CONS;
->andReturn(true) ->andReturn(true)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'add'); $console->setArgument(0, 'add');
$console->setArgument(1, 'pod.ordoevangelistarum.com'); $console->setArgument(1, 'pod.ordoevangelistarum.com');
$console->setArgument(2, 'Other reason'); $console->setArgument(2, 'Other reason');
@ -180,7 +180,7 @@ CONS;
->andReturn(true) ->andReturn(true)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'remove'); $console->setArgument(0, 'remove');
$console->setArgument(1, 'pod.ordoevangelistarum.com'); $console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -193,7 +193,7 @@ CONS;
*/ */
public function testBlockedServersWrongCommand() public function testBlockedServersWrongCommand()
{ {
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'wrongcommand'); $console->setArgument(0, 'wrongcommand');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -211,7 +211,7 @@ CONS;
->andReturn($this->defaultBlockList) ->andReturn($this->defaultBlockList)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'remove'); $console->setArgument(0, 'remove');
$console->setArgument(1, 'not.exiting'); $console->setArgument(1, 'not.exiting');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -224,7 +224,7 @@ CONS;
*/ */
public function testAddBlockedServerMissingArgument() public function testAddBlockedServerMissingArgument()
{ {
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'add'); $console->setArgument(0, 'add');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -245,7 +245,7 @@ CONS;
$newBlockList = $this->defaultBlockList; $newBlockList = $this->defaultBlockList;
$newBlockList[] = [ $newBlockList[] = [
'domain' => 'testme.now', 'domain' => 'testme.now',
'reason' => BlockedServers::DEFAULT_REASON, 'reason' => ServerBlock::DEFAULT_REASON,
]; ];
$this->configMock $this->configMock
@ -254,7 +254,7 @@ CONS;
->andReturn(false) ->andReturn(false)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'add'); $console->setArgument(0, 'add');
$console->setArgument(1, 'testme.now'); $console->setArgument(1, 'testme.now');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -286,7 +286,7 @@ CONS;
->andReturn(false) ->andReturn(false)
->once(); ->once();
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'remove'); $console->setArgument(0, 'remove');
$console->setArgument(1, 'pod.ordoevangelistarum.com'); $console->setArgument(1, 'pod.ordoevangelistarum.com');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -299,7 +299,7 @@ CONS;
*/ */
public function testRemoveBlockedServerMissingArgument() public function testRemoveBlockedServerMissingArgument()
{ {
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setArgument(0, 'remove'); $console->setArgument(0, 'remove');
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
@ -311,16 +311,16 @@ CONS;
*/ */
public function testBlockedServersHelp() public function testBlockedServersHelp()
{ {
$console = new BlockedServers($this->consoleArgv); $console = new ServerBlock($this->consoleArgv);
$console->setOption('help', true); $console->setOption('help', true);
$txt = $this->dumpExecute($console); $txt = $this->dumpExecute($console);
$help = <<<HELP $help = <<<HELP
console blockedservers - Manage blocked servers console serverblock - Manage blocked servers
Usage Usage
bin/console blockedservers [-h|--help|-?] [-v] bin/console serverblock [-h|--help|-?] [-v]
bin/console blockedservers add <server> <reason> [-h|--help|-?] [-v] bin/console serverblock add <server> <reason> [-h|--help|-?] [-v]
bin/console blockedservers remove <server> [-h|--help|-?] [-v] bin/console serverblock remove <server> [-h|--help|-?] [-v]
Description Description
With this tool, you can list the current blocked servers With this tool, you can list the current blocked servers