diff --git a/src/Core/Console.php b/src/Core/Console.php index d115143e47..0cc63a5913 100644 --- a/src/Core/Console.php +++ b/src/Core/Console.php @@ -13,34 +13,12 @@ class Console extends \Asika\SimpleConsole\Console protected $helpOptions = []; 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() { $help = << [] [-v] Commands: - blockedservers Manage blocked servers cache Manage node cache config Edit site config createdoxygen Generate Doxygen headers @@ -58,6 +36,7 @@ Commands: po2php Generate a strings.php file from a messages.po file typo Checks for parse errors in Friendica files postupdate Execute pending post update scripts (can last days) + serverblock Manage blocked servers storage Manage storage backend Options: @@ -67,6 +46,27 @@ 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() { if ($this->getOption('v')) { diff --git a/src/Core/Console/BlockedServers.php b/src/Core/Console/ServerBlock.php similarity index 93% rename from src/Core/Console/BlockedServers.php rename to src/Core/Console/ServerBlock.php index cd9d212984..94c97e1ddd 100644 --- a/src/Core/Console/BlockedServers.php +++ b/src/Core/Console/ServerBlock.php @@ -14,7 +14,7 @@ use Friendica\Core\Config\Configuration; * With this tool, you can list the current blocked servers * or you can add / remove a blocked server from the list */ -class BlockedServers extends Console +class ServerBlock extends Console { const DEFAULT_REASON = 'blocked'; @@ -23,11 +23,11 @@ class BlockedServers extends Console protected function getHelp() { $help = << [-h|--help|-?] [-v] - bin/console blockedservers remove [-h|--help|-?] [-v] + bin/console serverblock [-h|--help|-?] [-v] + bin/console serverblock add [-h|--help|-?] [-v] + bin/console serverblock remove [-h|--help|-?] [-v] Description With this tool, you can list the current blocked servers diff --git a/tests/src/Core/Console/BlockedServersConsoleTest.php b/tests/src/Core/Console/ServerBlockConsoleTest.php similarity index 86% rename from tests/src/Core/Console/BlockedServersConsoleTest.php rename to tests/src/Core/Console/ServerBlockConsoleTest.php index f33a8de31c..512a416f5e 100644 --- a/tests/src/Core/Console/BlockedServersConsoleTest.php +++ b/tests/src/Core/Console/ServerBlockConsoleTest.php @@ -2,13 +2,13 @@ namespace Friendica\Test\src\Core\Console; -use Friendica\Core\Console\BlockedServers; +use Friendica\Core\Console\ServerBlock; /** * @runTestsInSeparateProcesses * @preserveGlobalState disabled */ -class BlockedServersConsoleTest extends ConsoleTest +class ServerBlockConsoleTest extends ConsoleTest { protected $defaultBlockList = [ [ @@ -39,7 +39,7 @@ class BlockedServersConsoleTest extends ConsoleTest ->andReturn($this->defaultBlockList) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $txt = $this->dumpExecute($console); $output = <<andReturn(true) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'add'); $console->setArgument(1, 'testme.now'); $console->setArgument(2, 'I like it!'); @@ -102,7 +102,7 @@ CONS; $newBlockList = $this->defaultBlockList; $newBlockList[] = [ 'domain' => 'testme.now', - 'reason' => BlockedServers::DEFAULT_REASON, + 'reason' => ServerBlock::DEFAULT_REASON, ]; $this->configMock @@ -111,12 +111,12 @@ CONS; ->andReturn(true) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'add'); $console->setArgument(1, 'testme.now'); $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) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'add'); $console->setArgument(1, 'pod.ordoevangelistarum.com'); $console->setArgument(2, 'Other reason'); @@ -180,7 +180,7 @@ CONS; ->andReturn(true) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'remove'); $console->setArgument(1, 'pod.ordoevangelistarum.com'); $txt = $this->dumpExecute($console); @@ -193,7 +193,7 @@ CONS; */ public function testBlockedServersWrongCommand() { - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'wrongcommand'); $txt = $this->dumpExecute($console); @@ -211,7 +211,7 @@ CONS; ->andReturn($this->defaultBlockList) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'remove'); $console->setArgument(1, 'not.exiting'); $txt = $this->dumpExecute($console); @@ -224,7 +224,7 @@ CONS; */ public function testAddBlockedServerMissingArgument() { - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'add'); $txt = $this->dumpExecute($console); @@ -245,7 +245,7 @@ CONS; $newBlockList = $this->defaultBlockList; $newBlockList[] = [ 'domain' => 'testme.now', - 'reason' => BlockedServers::DEFAULT_REASON, + 'reason' => ServerBlock::DEFAULT_REASON, ]; $this->configMock @@ -254,7 +254,7 @@ CONS; ->andReturn(false) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'add'); $console->setArgument(1, 'testme.now'); $txt = $this->dumpExecute($console); @@ -286,7 +286,7 @@ CONS; ->andReturn(false) ->once(); - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'remove'); $console->setArgument(1, 'pod.ordoevangelistarum.com'); $txt = $this->dumpExecute($console); @@ -299,7 +299,7 @@ CONS; */ public function testRemoveBlockedServerMissingArgument() { - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setArgument(0, 'remove'); $txt = $this->dumpExecute($console); @@ -311,16 +311,16 @@ CONS; */ public function testBlockedServersHelp() { - $console = new BlockedServers($this->consoleArgv); + $console = new ServerBlock($this->consoleArgv); $console->setOption('help', true); $txt = $this->dumpExecute($console); $help = << [-h|--help|-?] [-v] - bin/console blockedservers remove [-h|--help|-?] [-v] + bin/console serverblock [-h|--help|-?] [-v] + bin/console serverblock add [-h|--help|-?] [-v] + bin/console serverblock remove [-h|--help|-?] [-v] Description With this tool, you can list the current blocked servers