mirror of
https://github.com/friendica/friendica
synced 2024-10-07 16:11:56 +02:00
Use DICE for Console
- Use Friendica\Core\Console as Controller for DI-library - Refactor every console command to use DICE (when possible) - Adjusting tests
This commit is contained in:
parent
b8a336cc0d
commit
a60eb9e33d
|
@ -6,6 +6,4 @@ require dirname(__DIR__) . '/vendor/autoload.php';
|
|||
$dice = new \Dice\Dice();
|
||||
$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
|
||||
|
||||
\Friendica\BaseObject::setDependencyInjection($dice);
|
||||
|
||||
(new Friendica\Core\Console($argv))->execute();
|
||||
(new Friendica\Core\Console($dice, $argv))->execute();
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Util\Strings;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -20,6 +21,19 @@ class ArchiveContact extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
/**
|
||||
* @var L10n\L10n
|
||||
*/
|
||||
private $l10n;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -37,10 +51,17 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Database $dba, L10n\L10n $l10n, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->dba = $dba;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
|
@ -56,16 +77,16 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new RuntimeException('Friendica isn\'t properly installed yet.');
|
||||
}
|
||||
|
||||
$nurl = Strings::normaliseLink($this->getArgument(0));
|
||||
if (!DBA::exists('contact', ['nurl' => $nurl, 'archive' => false])) {
|
||||
if (!$this->dba->exists('contact', ['nurl' => $nurl, 'archive' => false])) {
|
||||
throw new RuntimeException(L10n::t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
|
||||
}
|
||||
if (DBA::update('contact', ['archive' => true], ['nurl' => $nurl])) {
|
||||
$this->out(L10n::t('The contact entries have been archived'));
|
||||
if ($this->dba->update('contact', ['archive' => true], ['nurl' => $nurl])) {
|
||||
$this->out($this->l10n->t('The contact entries have been archived'));
|
||||
} else {
|
||||
throw new RuntimeException('The contact archival failed.');
|
||||
}
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
namespace Friendica\Console;
|
||||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Installer;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\BaseURL;
|
||||
use Friendica\Util\ConfigFileLoader;
|
||||
|
@ -14,6 +15,19 @@ use RuntimeException;
|
|||
|
||||
class AutomaticInstallation extends Console
|
||||
{
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Config\Cache\ConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
return <<<HELP
|
||||
|
@ -69,17 +83,25 @@ Examples
|
|||
HELP;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Database $dba, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->configCache =$configCache;
|
||||
$this->dba = $dba;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
// Initialise the app
|
||||
$this->out("Initializing setup...\n");
|
||||
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
$installer = new Installer();
|
||||
|
||||
$configCache = $a->getConfigCache();
|
||||
$basepath = new BasePath($a->getBasePath());
|
||||
$configCache = $this->configCache;
|
||||
$basePathConf = $configCache->get('system', 'basepath');
|
||||
$basepath = new BasePath($basePathConf);
|
||||
$installer->setUpCache($configCache, $basepath->getPath());
|
||||
|
||||
$this->out(" Complete!\n\n");
|
||||
|
@ -103,13 +125,13 @@ HELP;
|
|||
if ($config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
|
||||
// Copy config file
|
||||
$this->out("Copying config file...\n");
|
||||
if (!copy($a->getBasePath() . DIRECTORY_SEPARATOR . $config_file, $a->getBasePath() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $a->getBasePath() . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
|
||||
if (!copy($basePathConf . DIRECTORY_SEPARATOR . $config_file, $basePathConf . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $basePathConf . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
|
||||
}
|
||||
}
|
||||
|
||||
//reload the config cache
|
||||
$loader = new ConfigFileLoader($a->getBasePath(), $a->getMode());
|
||||
$loader = new ConfigFileLoader($basePathConf);
|
||||
$loader->setupCache($configCache);
|
||||
|
||||
} else {
|
||||
|
@ -159,7 +181,7 @@ HELP;
|
|||
$this->out('The Friendica URL has to be set during CLI installation.');
|
||||
return 1;
|
||||
} else {
|
||||
$baseUrl = new BaseURL($a->getConfig(), []);
|
||||
$baseUrl = new BaseURL($basePathConf, []);
|
||||
$baseUrl->saveByURL($url);
|
||||
}
|
||||
|
||||
|
@ -173,7 +195,7 @@ HELP;
|
|||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$installer->checkDB($configCache, $a->getProfiler())) {
|
||||
if (!$installer->checkDB($this->dba)) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
@ -185,7 +207,7 @@ HELP;
|
|||
|
||||
$installer->resetChecks();
|
||||
|
||||
if (!$installer->installDatabase($a->getBasePath())) {
|
||||
if (!$installer->installDatabase($basePathConf)) {
|
||||
$errorMessage = $this->extractErrors($installer->getChecks());
|
||||
throw new RuntimeException($errorMessage);
|
||||
}
|
||||
|
@ -194,8 +216,8 @@ HELP;
|
|||
|
||||
// Install theme
|
||||
$this->out("Installing theme\n");
|
||||
if (!empty(Config::get('system', 'theme'))) {
|
||||
Theme::install(Config::get('system', 'theme'));
|
||||
if (!empty($configCache->get('system', 'theme'))) {
|
||||
Theme::install($configCache->get('system', 'theme'));
|
||||
$this->out(" Complete\n\n");
|
||||
} else {
|
||||
$this->out(" Theme setting is empty. Please check the file 'config/local.config.php'\n\n");
|
||||
|
|
|
@ -20,6 +20,11 @@ class Cache extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -54,10 +59,15 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Executable: ' . $this->executable);
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
|
@ -65,7 +75,7 @@ HELP;
|
|||
$this->out('Options: ' . var_export($this->options, true));
|
||||
}
|
||||
|
||||
if ($a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Friendica\Console;
|
|||
|
||||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Friendica\App;
|
||||
use Friendica\Core;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,15 @@ class Config extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $config;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -69,10 +78,16 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Configuration $config, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Executable: ' . $this->executable);
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
|
@ -84,7 +99,7 @@ HELP;
|
|||
throw new CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, showing file config only');
|
||||
}
|
||||
|
||||
|
@ -93,14 +108,14 @@ HELP;
|
|||
$key = $this->getArgument(1);
|
||||
$value = $this->getArgument(2);
|
||||
|
||||
if (is_array(Core\Config::get($cat, $key))) {
|
||||
if (is_array($this->config->get($cat, $key))) {
|
||||
throw new RuntimeException("$cat.$key is an array and can't be set using this command.");
|
||||
}
|
||||
|
||||
$result = Core\Config::set($cat, $key, $value);
|
||||
$result = $this->config->set($cat, $key, $value);
|
||||
if ($result) {
|
||||
$this->out("{$cat}.{$key} <= " .
|
||||
Core\Config::get($cat, $key));
|
||||
$this->config->get($cat, $key));
|
||||
} else {
|
||||
$this->out("Unable to set {$cat}.{$key}");
|
||||
}
|
||||
|
@ -109,7 +124,7 @@ HELP;
|
|||
if (count($this->args) == 2) {
|
||||
$cat = $this->getArgument(0);
|
||||
$key = $this->getArgument(1);
|
||||
$value = Core\Config::get($this->getArgument(0), $this->getArgument(1));
|
||||
$value = $this->config->get($this->getArgument(0), $this->getArgument(1));
|
||||
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
|
@ -122,11 +137,12 @@ HELP;
|
|||
|
||||
if (count($this->args) == 1) {
|
||||
$cat = $this->getArgument(0);
|
||||
Core\Config::load($cat);
|
||||
$this->config->load($cat);
|
||||
$configCache = $this->config->getCache();
|
||||
|
||||
if ($a->getConfigCache()->get($cat) !== null) {
|
||||
if ($configCache->get($cat) !== null) {
|
||||
$this->out("[{$cat}]");
|
||||
$catVal = $a->getConfigCache()->get($cat);
|
||||
$catVal = $configCache->get($cat);
|
||||
foreach ($catVal as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
|
@ -142,13 +158,13 @@ HELP;
|
|||
}
|
||||
|
||||
if (count($this->args) == 0) {
|
||||
Core\Config::load();
|
||||
$this->config->load();
|
||||
|
||||
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if ($this->config->get('system', 'config_adapter') == 'jit' && $this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
|
||||
}
|
||||
|
||||
$config = $a->getConfigCache()->getAll();
|
||||
$config = $this->config->getCache()->getAll();
|
||||
foreach ($config as $cat => $section) {
|
||||
if (is_array($section)) {
|
||||
foreach ($section as $key => $value) {
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\Core;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Update;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -17,6 +17,15 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
/**
|
||||
* @var ConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -39,6 +48,14 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Database $dba, ConfigCache $configCache, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->dba = $dba;
|
||||
$this->configCache = $configCache;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -56,26 +73,24 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if (!DBA::connected()) {
|
||||
if (!$this->dba->isConnected()) {
|
||||
throw new RuntimeException('Unable to connect to database');
|
||||
}
|
||||
|
||||
Core\Config::load();
|
||||
|
||||
$a = get_app();
|
||||
$basePath = $this->configCache->get('system', 'basepath');
|
||||
|
||||
switch ($this->getArgument(0)) {
|
||||
case "dryrun":
|
||||
$output = DBStructure::update($a->getBasePath(), true, false);
|
||||
$output = DBStructure::update($basePath, true, false);
|
||||
break;
|
||||
case "update":
|
||||
$force = $this->getOption(['f', 'force'], false);
|
||||
$override = $this->getOption(['o', 'override'], false);
|
||||
$output = Update::run($a->getBasePath(), $force, $override,true, false);
|
||||
$output = Update::run($basePath, $force, $override,true, false);
|
||||
break;
|
||||
case "dumpsql":
|
||||
ob_start();
|
||||
DBStructure::printStructure($a->getBasePath());
|
||||
DBStructure::printStructure($basePath);
|
||||
$output = ob_get_clean();
|
||||
break;
|
||||
case "toinnodb":
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Model\Contact;
|
||||
|
||||
|
@ -20,6 +21,15 @@ class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var L10n\L10n
|
||||
*/
|
||||
private $l10n;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -38,10 +48,16 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, L10n $l10n, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
|
@ -57,18 +73,18 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
$contact_id = Contact::getIdForURL($this->getArgument(0));
|
||||
if (!$contact_id) {
|
||||
throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $this->getArgument(0)));
|
||||
throw new \RuntimeException($this->l10n->t('Could not find any contact entry for this URL (%s)', $this->getArgument(0)));
|
||||
}
|
||||
|
||||
$block_reason = $this->getArgument(1);
|
||||
if(Contact::block($contact_id, $block_reason)) {
|
||||
$this->out(L10n::t('The contact has been blocked from the node'));
|
||||
$this->out($this->l10n->t('The contact has been blocked from the node'));
|
||||
} else {
|
||||
throw new \RuntimeException('The contact block failed.');
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\App;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model\Contact;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -24,6 +24,15 @@ class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -44,6 +53,14 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Database $dba, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->dba =$dba;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -61,13 +78,13 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if (BaseObject::getApp()->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
$contact_id = Contact::getIdForURL($this->getArgument(0));
|
||||
if ($contact_id) {
|
||||
DBA::update('contact', ['hidden' => true], ['id' => $contact_id]);
|
||||
$this->dba->update('contact', ['hidden' => true], ['id' => $contact_id]);
|
||||
$this->out('The account has been successfully silenced from the global community page.');
|
||||
} else {
|
||||
throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\Core;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
|
||||
/**
|
||||
* @brief Sets maintenance mode for this node
|
||||
|
@ -13,6 +14,15 @@ class Maintenance extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $config;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -42,10 +52,16 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Configuration $config, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
|
@ -61,20 +77,20 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
$enabled = intval($this->getArgument(0));
|
||||
|
||||
Core\Config::set('system', 'maintenance', $enabled);
|
||||
$this->config->set('system', 'maintenance', $enabled);
|
||||
|
||||
$reason = $this->getArgument(1);
|
||||
|
||||
if ($enabled && $this->getArgument(1)) {
|
||||
Core\Config::set('system', 'maintenance_reason', $this->getArgument(1));
|
||||
$this->config->set('system', 'maintenance_reason', $this->getArgument(1));
|
||||
} else {
|
||||
Core\Config::set('system', 'maintenance_reason', '');
|
||||
$this->config->set('system', 'maintenance_reason', '');
|
||||
}
|
||||
|
||||
if ($enabled) {
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n\L10n;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model\User;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -20,6 +21,19 @@ class NewPassword extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var L10n
|
||||
*/
|
||||
private $l10n;
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -37,10 +51,17 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, L10n $l10n, Database $dba, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->l10n = $l10n;
|
||||
$this->dba = $dba;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Class: ' . __CLASS__);
|
||||
$this->out('Arguments: ' . var_export($this->args, true));
|
||||
|
@ -56,31 +77,31 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
$nick = $this->getArgument(0);
|
||||
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
|
||||
if (!DBA::isResult($user)) {
|
||||
throw new RuntimeException(L10n::t('User not found'));
|
||||
$user = $this->dba->selectFirst('user', ['uid'], ['nickname' => $nick]);
|
||||
if (!$this->dba->isResult($user)) {
|
||||
throw new RuntimeException($this->l10n->t('User not found'));
|
||||
}
|
||||
|
||||
$password = $this->getArgument(1);
|
||||
if (is_null($password)) {
|
||||
$this->out(L10n::t('Enter new password: '), false);
|
||||
$this->out($this->l10n->t('Enter new password: '), false);
|
||||
$password = \Seld\CliPrompt\CliPrompt::hiddenPrompt(true);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = User::updatePassword($user['uid'], $password);
|
||||
|
||||
if (!DBA::isResult($result)) {
|
||||
throw new \Exception(L10n::t('Password update failed. Please try again.'));
|
||||
if (!$this->dba->isResult($result)) {
|
||||
throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
|
||||
}
|
||||
|
||||
$this->out(L10n::t('Password changed.'));
|
||||
$this->out($this->l10n->t('Password changed.'));
|
||||
} catch (\Exception $e) {
|
||||
throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
use Friendica\Core\L10n\L10n;
|
||||
use Friendica\Core\Update;
|
||||
|
||||
/**
|
||||
|
@ -16,11 +17,24 @@ use Friendica\Core\Update;
|
|||
*/
|
||||
class PostUpdate extends \Asika\SimpleConsole\Console
|
||||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $config;
|
||||
/**
|
||||
* @var L10n
|
||||
*/
|
||||
private $l10n;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
console postupdate - Performs database post updates
|
||||
Usage
|
||||
bin/console postupdate [-h|--help|-?] [--reset <version>]
|
||||
|
@ -29,8 +43,17 @@ Options
|
|||
-h|--help|-? Show help information
|
||||
--reset <version> Reset the post update version
|
||||
HELP;
|
||||
return $help;
|
||||
}
|
||||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(App\Mode $appMode, Configuration $config, L10n $l10n, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->appMode = $appMode;
|
||||
$this->config = $config;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
|
@ -46,26 +69,26 @@ HELP;
|
|||
$this->out($this->getHelp());
|
||||
return 0;
|
||||
} elseif ($reset_version) {
|
||||
Config::set('system', 'post_update_version', $reset_version);
|
||||
echo L10n::t('Post update version number has been set to %s.', $reset_version) . "\n";
|
||||
$this->config->set('system', 'post_update_version', $reset_version);
|
||||
echo $this->l10n->t('Post update version number has been set to %s.', $reset_version) . "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($a->getMode()->isInstall()) {
|
||||
if ($this->appMode->isInstall()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
echo L10n::t('Check for pending update actions.') . "\n";
|
||||
echo $this->l10n->t('Check for pending update actions.') . "\n";
|
||||
Update::run($a->getBasePath(), true, false, true, false);
|
||||
echo L10n::t('Done.') . "\n";
|
||||
echo $this->l10n->t('Done.') . "\n";
|
||||
|
||||
echo L10n::t('Execute pending post updates.') . "\n";
|
||||
echo $this->l10n->t('Execute pending post updates.') . "\n";
|
||||
|
||||
while (!\Friendica\Database\PostUpdate::update()) {
|
||||
echo '.';
|
||||
}
|
||||
|
||||
echo "\n" . L10n::t('All pending post updates are done.') . "\n";
|
||||
echo "\n" . $this->l10n->t('All pending post updates are done.') . "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Friendica\Console;
|
|||
use Asika\SimpleConsole\CommandArgsException;
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Console_Table;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +19,11 @@ class ServerBlock extends Console
|
|||
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $config;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -45,20 +49,25 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Configuration $config, $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
if (count($this->args) == 0) {
|
||||
$this->printBlockedServers($a->getConfig());
|
||||
$this->printBlockedServers($this->config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch ($this->getArgument(0)) {
|
||||
case 'add':
|
||||
return $this->addBlockedServer($a->getConfig());
|
||||
return $this->addBlockedServer($this->config);
|
||||
case 'remove':
|
||||
return $this->removeBlockedServer($a->getConfig());
|
||||
return $this->removeBlockedServer($this->config);
|
||||
default:
|
||||
throw new CommandArgsException('Unknown command.');
|
||||
break;
|
||||
|
@ -74,7 +83,7 @@ HELP;
|
|||
{
|
||||
$table = new Console_Table();
|
||||
$table->setHeaders(['Domain', 'Reason']);
|
||||
$blocklist = $config->get('system', 'blocklist');
|
||||
$blocklist = $config->get('system', 'blocklist', []);
|
||||
foreach ($blocklist as $domain) {
|
||||
$table->addRow($domain);
|
||||
}
|
||||
|
@ -99,7 +108,7 @@ HELP;
|
|||
|
||||
$update = false;
|
||||
|
||||
$currBlocklist = $config->get('system', 'blocklist');
|
||||
$currBlocklist = $config->get('system', 'blocklist', []);
|
||||
$newBlockList = [];
|
||||
foreach ($currBlocklist as $blocked) {
|
||||
if ($blocked['domain'] === $domain) {
|
||||
|
@ -150,7 +159,7 @@ HELP;
|
|||
|
||||
$found = false;
|
||||
|
||||
$currBlocklist = $config->get('system', 'blocklist');
|
||||
$currBlocklist = $config->get('system', 'blocklist', []);
|
||||
$newBlockList = [];
|
||||
foreach ($currBlocklist as $blocked) {
|
||||
if ($blocked['domain'] === $domain) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
|
||||
/**
|
||||
* Tired of chasing typos and finding them after a commit.
|
||||
|
@ -14,6 +14,11 @@ class Typo extends \Asika\SimpleConsole\Console
|
|||
{
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $config;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -31,6 +36,13 @@ HELP;
|
|||
return $help;
|
||||
}
|
||||
|
||||
public function __construct(Configuration $config, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -43,7 +55,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
$php_path = BaseObject::getApp()->getConfig()->get('config', 'php_path', 'php');
|
||||
$php_path = $this->config->get('config', 'php_path', 'php');
|
||||
|
||||
if ($this->getOption('v')) {
|
||||
$this->out('Directory: src');
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +16,11 @@ class Console extends \Asika\SimpleConsole\Console
|
|||
protected $helpOptions = [];
|
||||
protected $customHelpOptions = ['h', 'help', '?'];
|
||||
|
||||
/**
|
||||
* @var Dice The DI library
|
||||
*/
|
||||
protected $dice;
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -69,6 +75,19 @@ HELP;
|
|||
'storage' => Friendica\Console\Storage::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* CliInput Friendica constructor.
|
||||
*
|
||||
* @param Dice $dice The DI library
|
||||
* @param array $argv
|
||||
*/
|
||||
public function __construct(Dice $dice, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->dice = $dice;
|
||||
}
|
||||
|
||||
protected function doExecute()
|
||||
{
|
||||
if ($this->getOption('v')) {
|
||||
|
@ -125,8 +144,10 @@ HELP;
|
|||
|
||||
$className = $this->subConsoles[$command];
|
||||
|
||||
Friendica\BaseObject::setDependencyInjection($this->dice);
|
||||
|
||||
/** @var Console $subconsole */
|
||||
$subconsole = new $className($subargs);
|
||||
$subconsole = $this->dice->create($className, [$subargs]);
|
||||
|
||||
foreach ($this->options as $name => $value) {
|
||||
$subconsole->setOption($name, $value);
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Friendica\Core;
|
|||
use DOMDocument;
|
||||
use Exception;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -597,11 +597,11 @@ class Installer
|
|||
* @return bool true if the check was successful, otherwise false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkDB(ConfigCache $configCache, Profiler $profiler)
|
||||
public function checkDB(Database $dba)
|
||||
{
|
||||
DBA::reconnect();
|
||||
$dba->reconnect();
|
||||
|
||||
if (DBA::connected()) {
|
||||
if ($dba->isConnected()) {
|
||||
if (DBStructure::existsTable('user')) {
|
||||
$this->addCheck(L10n::t('Database already in use.'), false, true, '');
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ return [
|
|||
],
|
||||
],
|
||||
Config\Configuration::class => [
|
||||
'shared' => true,
|
||||
'instanceOf' => Factory\ConfigFactory::class,
|
||||
'call' => [
|
||||
['createConfig', [], Dice::CHAIN_CALL],
|
||||
|
|
|
@ -2,24 +2,28 @@
|
|||
|
||||
namespace Friendica\Test\src\Console;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Console\AutomaticInstallation;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Installer;
|
||||
use Friendica\Core\L10n\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Test\Util\DBAMockTrait;
|
||||
use Friendica\Test\Util\DBStructureMockTrait;
|
||||
use Friendica\Test\Util\RendererMockTrait;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Util\BaseURL;
|
||||
use Friendica\Util\Logger\VoidLogger;
|
||||
use Mockery\MockInterface;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamFile;
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||
{
|
||||
use VFSTrait;
|
||||
use DBAMockTrait;
|
||||
use DBStructureMockTrait;
|
||||
use RendererMockTrait;
|
||||
|
@ -38,28 +42,49 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
|||
*/
|
||||
private $configCache;
|
||||
|
||||
/**
|
||||
* @var App\Mode
|
||||
*/
|
||||
private $appMode;
|
||||
|
||||
/**
|
||||
* @var Database
|
||||
*/
|
||||
private $dba;
|
||||
|
||||
/**
|
||||
* @var Dice|MockInterface
|
||||
*/
|
||||
private $dice;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpVfsDir();;
|
||||
|
||||
if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
$this->root->getChild('config')
|
||||
->removeChild('local.config.php');
|
||||
}
|
||||
$this->dice = \Mockery::mock(Dice::class)->makePartial();
|
||||
|
||||
$l10nMock = \Mockery::mock(L10n::class);
|
||||
$l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
\Friendica\Core\L10n::init($l10nMock);
|
||||
|
||||
$this->dice->shouldReceive('create')
|
||||
->with(L10n::class)
|
||||
->andReturn($l10nMock);
|
||||
|
||||
BaseObject::setDependencyInjection($this->dice);
|
||||
|
||||
$this->configCache = new ConfigCache();
|
||||
$this->configCache->set('system', 'basepath', $this->root->url());
|
||||
$this->configCache->set('config', 'php_path', trim(shell_exec('which php')));
|
||||
$this->configCache->set('system', 'theme', 'smarty3');
|
||||
|
||||
$this->mockApp($this->root, true);
|
||||
|
||||
$this->configMock->shouldReceive('set')->andReturnUsing(function ($cat, $key, $value) {
|
||||
if ($key !== 'basepath') {
|
||||
return $this->configCache->set($cat, $key, $value);
|
||||
|
|
|
@ -2,35 +2,38 @@
|
|||
|
||||
namespace Friendica\Test\src\Console;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Console\Config;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
class ConfigConsoleTest extends ConsoleTest
|
||||
{
|
||||
/**
|
||||
* @var App\Mode|MockInterface $appMode
|
||||
*/
|
||||
private $appMode;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mockApp($this->root);
|
||||
|
||||
\Mockery::getConfiguration()->setConstantsMap([
|
||||
Mode::class => [
|
||||
'DBCONFIGAVAILABLE' => 0
|
||||
]
|
||||
]);
|
||||
|
||||
$this->mode
|
||||
->shouldReceive('has')
|
||||
->andReturn(true);
|
||||
$this->appMode = \Mockery::mock(App\Mode::class);
|
||||
$this->appMode->shouldReceive('has')
|
||||
->andReturn(true);
|
||||
|
||||
$this->configMock = \Mockery::mock(Configuration::class);
|
||||
}
|
||||
|
||||
function testSetGetKeyValue() {
|
||||
function testSetGetKeyValue()
|
||||
{
|
||||
$this->configMock
|
||||
->shouldReceive('set')
|
||||
->with('config', 'test', 'now')
|
||||
|
@ -42,7 +45,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
->andReturn('now')
|
||||
->twice();
|
||||
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$console->setArgument(2, 'now');
|
||||
|
@ -55,7 +58,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
->andReturn('now')
|
||||
->once();
|
||||
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, [$this->consoleArgv]);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$txt = $this->dumpExecute($console);
|
||||
|
@ -67,7 +70,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
->andReturn(null)
|
||||
->once();
|
||||
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$txt = $this->dumpExecute($console);
|
||||
|
@ -82,7 +85,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
->andReturn($testArray)
|
||||
->once();
|
||||
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$console->setArgument(2, 'now');
|
||||
|
@ -92,7 +95,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
}
|
||||
|
||||
function testTooManyArguments() {
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$console->setArgument(2, 'it');
|
||||
|
@ -109,7 +112,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
->with('test', 'it')
|
||||
->andReturn('now')
|
||||
->once();
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'test');
|
||||
$console->setArgument(1, 'it');
|
||||
$console->setOption('v', 1);
|
||||
|
@ -142,7 +145,7 @@ CONF;
|
|||
->with('test', 'it')
|
||||
->andReturn(NULL)
|
||||
->once();
|
||||
$console = new Config();
|
||||
$console = new Config($this->appMode, $this->configMock, [$this->consoleArgv]);
|
||||
$console->setArgument(0, 'test');
|
||||
$console->setArgument(1, 'it');
|
||||
$console->setArgument(2, 'now');
|
||||
|
@ -183,7 +186,7 @@ Options
|
|||
-v Show more debug information.
|
||||
|
||||
HELP;
|
||||
$console = new Config($this->consoleArgv);
|
||||
$console = new Config($this->appMode, $this->configMock, [$this->consoleArgv]);
|
||||
$console->setOption('help', true);
|
||||
|
||||
$txt = $this->dumpExecute($console);
|
||||
|
|
|
@ -4,15 +4,10 @@ namespace Friendica\Test\src\Console;
|
|||
|
||||
use Asika\SimpleConsole\Console;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\AppMockTrait;
|
||||
use Friendica\Test\Util\Intercept;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
|
||||
abstract class ConsoleTest extends MockedTest
|
||||
{
|
||||
use VFSTrait;
|
||||
use AppMockTrait;
|
||||
|
||||
/**
|
||||
* @var array The default argv for a Console Instance
|
||||
*/
|
||||
|
@ -23,8 +18,6 @@ abstract class ConsoleTest extends MockedTest
|
|||
parent::setUp();
|
||||
|
||||
Intercept::setUp();
|
||||
|
||||
$this->setUpVfsDir();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
namespace Friendica\Test\src\Console;
|
||||
|
||||
use Friendica\Console\ServerBlock;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
|
||||
/**
|
||||
< |