mirror of
https://github.com/friendica/friendica
synced 2025-04-26 01:50:11 +00:00
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:
parent
5014779052
commit
31148e25cf
21 changed files with 498 additions and 106 deletions
|
@ -31,7 +31,7 @@ class Config extends BaseObject
|
|||
public static function init()
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Config extends BaseObject
|
|||
public static function load($family = "config")
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Config extends BaseObject
|
|||
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Database isn't ready or populated yet, fallback to file config
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return self::getApp()->getConfigValue($family, $key, $default_value);
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Config extends BaseObject
|
|||
public static function set($family, $key, $value)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Config extends BaseObject
|
|||
public static function delete($family, $key)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,14 @@ class PConfig extends BaseObject
|
|||
|
||||
public static function init($uid)
|
||||
{
|
||||
$a = self::getApp();
|
||||
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!$a->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self::getApp()->getConfigValue('system', 'config_adapter') == 'preload') {
|
||||
if ($a->getConfigValue('system', 'config_adapter') == 'preload') {
|
||||
self::$adapter = new Config\PreloadPConfigAdapter($uid);
|
||||
} else {
|
||||
self::$adapter = new Config\JITPConfigAdapter($uid);
|
||||
|
@ -55,7 +57,7 @@ class PConfig extends BaseObject
|
|||
public static function load($uid, $family)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,7 +86,7 @@ class PConfig extends BaseObject
|
|||
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,7 +115,7 @@ class PConfig extends BaseObject
|
|||
public static function set($uid, $family, $key, $value)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,7 +141,7 @@ class PConfig extends BaseObject
|
|||
public static function delete($uid, $family, $key)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!self::getApp()->getMode()->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue