1
0
Fork 0

Changing Friendica\App\Mode from static methods to public methods

- Changing from static methods to public methods
- Adding dev-composer-dependency Mockery for static method mocking (f.e. Config, DBA)
- Adding ModeTest with Mocking
- removing bootstrap from phpunit.xml because of double loading tests\bootstrap.php
This commit is contained in:
Philipp Holzer 2018-10-06 16:27:20 +02:00
commit 31148e25cf
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
21 changed files with 498 additions and 106 deletions

View file

@ -39,7 +39,7 @@ HELP;
protected function doExecute()
{
$a = get_app();
$a = \Friendica\BaseObject::getApp();
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
@ -56,7 +56,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new RuntimeException('Friendica isn\'t properly installed yet.');
}

View file

@ -65,7 +65,7 @@ HELP;
$this->out('Options: ' . var_export($this->options, true));
}
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
if ($a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
}

View file

@ -84,7 +84,7 @@ HELP;
throw new CommandArgsException('Too many arguments');
}
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, showing file config only');
}
@ -143,7 +143,7 @@ HELP;
if (count($this->args) == 0) {
Core\Config::load();
if (Core\Config::get('system', 'config_adapter') == 'jit' && App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->getMode()->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');
}

View file

@ -56,7 +56,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
}

View file

@ -65,7 +65,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new RuntimeException('Database isn\'t ready or populated yet');
}

View file

@ -47,7 +47,7 @@ HELP;
protected function doExecute()
{
$a = get_app();
$a = \Friendica\BaseObject::getApp();
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
@ -64,7 +64,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
}

View file

@ -57,7 +57,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new RuntimeException('Database isn\'t ready or populated yet');
}

View file

@ -33,7 +33,7 @@ HELP;
protected function doExecute()
{
$a = get_app();
$a = \Friendica\BaseObject::getApp();
if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp());
@ -50,7 +50,7 @@ HELP;
return 0;
}
if (App\Mode::isInstall()) {
if ($a->getMode()->isInstall()) {
throw new \RuntimeException('Database isn\'t ready or populated yet');
}