From d5a473abdaa019b6b3747ef6ee15c6202cec839b Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 19 Jan 2020 22:23:44 +0100 Subject: [PATCH] Shorten "PConfiguration" to "PConfig" again, since the Wrapper is gone --- index.php | 2 +- src/App.php | 19 ++++++----- src/App/Authentication.php | 8 ++--- src/App/Mode.php | 4 +-- src/App/Page.php | 30 ++++++++-------- src/Console/AutomaticInstallation.php | 10 +++--- src/Console/DatabaseStructure.php | 6 ++-- src/Core/BaseConfig.php | 8 ++--- .../PConfiguration.php => BasePConfig.php} | 16 +++++---- .../{Cache/ConfigCache.php => Cache.php} | 4 +-- src/Core/Config/IConfig.php | 6 ++-- src/Core/Config/JitConfig.php | 4 +-- src/Core/Config/PreloadConfig.php | 4 +-- src/Core/Installer.php | 12 +++---- .../PConfigCache.php => PConfig/Cache.php} | 4 +-- .../IPConfig.php} | 8 ++--- .../JitPConfig.php} | 9 ++--- .../PreloadPConfig.php} | 9 ++--- src/DI.php | 4 +-- src/Database/Database.php | 6 ++-- src/Factory/ConfigFactory.php | 24 ++++++------- src/Model/Notify.php | 6 ++-- src/Module/Admin/Summary.php | 2 +- src/Module/Install.php | 6 ++-- src/Util/ConfigFileLoader.php | 14 ++++---- src/Util/Profiler.php | 6 ++-- static/dependencies.config.php | 14 ++++---- tests/Util/AppMockTrait.php | 4 +-- tests/functional/DependencyCheckTest.php | 6 ++-- tests/include/ApiTest.php | 8 ++--- tests/src/App/ModeTest.php | 4 +-- .../AutomaticInstallationConsoleTest.php | 6 ++-- .../src/Core/Config/Cache/ConfigCacheTest.php | 34 +++++++++---------- .../Core/Config/Cache/PConfigCacheTest.php | 28 +++++++-------- tests/src/Core/Config/ConfigurationTest.php | 26 +++++++------- .../src/Core/Config/JitPConfigurationTest.php | 4 +-- tests/src/Core/Config/PConfigurationTest.php | 32 ++++++++--------- .../Core/Config/PreloadPConfigurationTest.php | 4 +-- tests/src/Core/InstallerTest.php | 4 +-- .../src/Util/Config/ConfigFileLoaderTest.php | 18 +++++----- tests/src/Util/ProfilerTest.php | 12 +++---- 41 files changed, 219 insertions(+), 216 deletions(-) rename src/Core/{Config/PConfiguration.php => BasePConfig.php} (62%) rename src/Core/Config/{Cache/ConfigCache.php => Cache.php} (98%) rename src/Core/{Config/Cache/PConfigCache.php => PConfig/Cache.php} (98%) rename src/Core/{Config/IPConfiguration.php => PConfig/IPConfig.php} (95%) rename src/Core/{Config/JitPConfiguration.php => PConfig/JitPConfig.php} (91%) rename src/Core/{Config/PreloadPConfiguration.php => PConfig/PreloadPConfig.php} (91%) diff --git a/index.php b/index.php index 1a88a7b283..7a6e26b42e 100644 --- a/index.php +++ b/index.php @@ -22,7 +22,7 @@ $a = \Friendica\DI::app(); $a->runFrontend( $dice->create(\Friendica\App\Module::class), $dice->create(\Friendica\App\Router::class), - $dice->create(\Friendica\Core\Config\IPConfiguration::class), + $dice->create(\Friendica\Core\PConfig\IPConfig::class), $dice->create(\Friendica\App\Authentication::class), $dice->create(\Friendica\App\Page::class) ); diff --git a/src/App.php b/src/App.php index cfe2c1c1b4..ceb11dd797 100644 --- a/src/App.php +++ b/src/App.php @@ -8,9 +8,9 @@ use Exception; use Friendica\App\Arguments; use Friendica\App\BaseURL; use Friendica\App\Authentication; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Config\IConfig; -use Friendica\Core\Config\IPConfiguration; +use Friendica\Core\PConfig\IPConfig; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Core\Theme; @@ -118,14 +118,14 @@ class App private $process; /** - * @var IPConfiguration + * @var IPConfig */ private $pConfig; /** * Returns the current config cache of this node * - * @return ConfigCache + * @return Cache */ public function getConfigCache() { @@ -153,9 +153,9 @@ class App * @param L10n $l10n The translator instance * @param App\Arguments $args The Friendica Arguments of the call * @param Core\Process $process The process methods - * @param IPConfiguration $pConfig Personal configuration + * @param IPConfig $pConfig Personal configuration */ - public function __construct(Database $database, IConfig $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfiguration $pConfig) + public function __construct(Database $database, IConfig $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfig $pConfig) { $this->database = $database; $this->config = $config; @@ -432,13 +432,14 @@ class App * * @param App\Module $module The determined module * @param App\Router $router - * @param IPConfiguration $pconfig + * @param IPConfig $pconfig * @param Authentication $auth The Authentication backend of the node - * @param App\Page $page The Friendica page printing container + * @param App\Page $page The Friendica page printing container + * * @throws HTTPException\InternalServerErrorException * @throws \ImagickException */ - public function runFrontend(App\Module $module, App\Router $router, IPConfiguration $pconfig, Authentication $auth, App\Page $page) + public function runFrontend(App\Module $module, App\Router $router, IPConfig $pconfig, Authentication $auth, App\Page $page) { $moduleName = $module->getName(); diff --git a/src/App/Authentication.php b/src/App/Authentication.php index 9dfc6adb15..c0408a8111 100644 --- a/src/App/Authentication.php +++ b/src/App/Authentication.php @@ -9,7 +9,7 @@ namespace Friendica\App; use Exception; use Friendica\App; use Friendica\Core\Config\IConfig; -use Friendica\Core\Config\IPConfiguration; +use Friendica\Core\PConfig\IPConfig; use Friendica\Core\Hook; use Friendica\Core\Session; use Friendica\Core\System; @@ -46,7 +46,7 @@ class Authentication private $cookie; /** @var Session\ISession */ private $session; - /** @var IPConfiguration */ + /** @var IPConfig */ private $pConfig; /** @@ -60,9 +60,9 @@ class Authentication * @param LoggerInterface $logger * @param User\Cookie $cookie * @param Session\ISession $session - * @param IPConfiguration $pConfig + * @param IPConfig $pConfig */ - public function __construct(IConfig $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfiguration $pConfig) + public function __construct(IConfig $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfig $pConfig) { $this->config = $config; $this->mode = $mode; diff --git a/src/App/Mode.php b/src/App/Mode.php index 0a5f98e24f..6cef3456b1 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -3,7 +3,7 @@ namespace Friendica\App; use Detection\MobileDetect; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Database\Database; use Friendica\Util\BasePath; @@ -65,7 +65,7 @@ class Mode * * @throws \Exception */ - public function determine(BasePath $basepath, Database $database, ConfigCache $configCache) + public function determine(BasePath $basepath, Database $database, Cache $configCache) { $mode = 0; diff --git a/src/App/Page.php b/src/App/Page.php index 408f803225..8dd8763465 100644 --- a/src/App/Page.php +++ b/src/App/Page.php @@ -8,7 +8,7 @@ use DOMXPath; use Friendica\App; use Friendica\Content\Nav; use Friendica\Core\Config\IConfig; -use Friendica\Core\Config\IPConfiguration; +use Friendica\Core\PConfig\IPConfig; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Renderer; @@ -168,15 +168,15 @@ class Page implements ArrayAccess * - Infinite scroll data * - head.tpl template * - * @param App $app The Friendica App instance - * @param Module $module The loaded Friendica module - * @param L10n $l10n The l10n language instance - * @param IConfig $config The Friendica configuration - * @param IPConfiguration $pConfig The Friendica personal configuration (for user) + * @param App $app The Friendica App instance + * @param Module $module The loaded Friendica module + * @param L10n $l10n The l10n language instance + * @param IConfig $config The Friendica configuration + * @param IPConfig $pConfig The Friendica personal configuration (for user) * * @throws HTTPException\InternalServerErrorException */ - private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pConfig) + private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfig $pConfig) { $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000); @@ -342,17 +342,17 @@ class Page implements ArrayAccess /** * Executes the creation of the current page and prints it to the screen * - * @param App $app The Friendica App - * @param BaseURL $baseURL The Friendica Base URL - * @param Mode $mode The current node mode - * @param Module $module The loaded Friendica module - * @param L10n $l10n The l10n language class - * @param IConfig $config The Configuration of this node - * @param IPConfiguration $pconfig The personal/user configuration + * @param App $app The Friendica App + * @param BaseURL $baseURL The Friendica Base URL + * @param Mode $mode The current node mode + * @param Module $module The loaded Friendica module + * @param L10n $l10n The l10n language class + * @param IConfig $config The Configuration of this node + * @param IPConfig $pconfig The personal/user configuration * * @throws HTTPException\InternalServerErrorException */ - public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pconfig) + public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfig $pconfig) { $moduleName = $module->getName(); diff --git a/src/Console/AutomaticInstallation.php b/src/Console/AutomaticInstallation.php index 12c3b325ae..f93b50c1e2 100644 --- a/src/Console/AutomaticInstallation.php +++ b/src/Console/AutomaticInstallation.php @@ -20,7 +20,7 @@ class AutomaticInstallation extends Console */ private $appMode; /** - * @var Config\Cache\ConfigCache + * @var \Friendica\Core\Config\Cache */ private $configCache; @@ -89,7 +89,7 @@ Examples HELP; } - public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfig $config, Database $dba, array $argv = null) + public function __construct(App\Mode $appMode, Config\Cache $configCache, Config\IConfig $config, Database $dba, array $argv = null) { parent::__construct($argv); @@ -241,13 +241,13 @@ HELP; } /** - * @param Installer $installer The Installer instance - * @param Config\Cache\ConfigCache $configCache The config cache + * @param Installer $installer The Installer instance + * @param \Friendica\Core\Config\Cache $configCache The config cache * * @return bool true if checks were successfully, otherwise false * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - private function runBasicChecks(Installer $installer, Config\Cache\ConfigCache $configCache) + private function runBasicChecks(Installer $installer, Config\Cache $configCache) { $checked = true; diff --git a/src/Console/DatabaseStructure.php b/src/Console/DatabaseStructure.php index b397c8f50d..d7de1f3d0c 100644 --- a/src/Console/DatabaseStructure.php +++ b/src/Console/DatabaseStructure.php @@ -2,7 +2,7 @@ namespace Friendica\Console; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Update; use Friendica\Database\Database; use Friendica\Database\DBStructure; @@ -22,7 +22,7 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console */ private $dba; /** - * @var ConfigCache + * @var Cache */ private $configCache; @@ -48,7 +48,7 @@ HELP; return $help; } - public function __construct(Database $dba, ConfigCache $configCache, $argv = null) + public function __construct(Database $dba, Cache $configCache, $argv = null) { parent::__construct($argv); diff --git a/src/Core/BaseConfig.php b/src/Core/BaseConfig.php index b464beed1b..744e5cc498 100644 --- a/src/Core/BaseConfig.php +++ b/src/Core/BaseConfig.php @@ -15,7 +15,7 @@ use Friendica\Model; abstract class BaseConfig implements IConfig { /** - * @var Cache\ConfigCache + * @var Cache */ protected $configCache; @@ -25,10 +25,10 @@ abstract class BaseConfig implements IConfig protected $configModel; /** - * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files) - * @param Model\Config\Config $configModel The configuration model + * @param Cache $configCache The configuration cache (based on the config-files) + * @param Model\Config\Config $configModel The configuration model */ - public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel) + public function __construct(Cache $configCache, Model\Config\Config $configModel) { $this->configCache = $configCache; $this->configModel = $configModel; diff --git a/src/Core/Config/PConfiguration.php b/src/Core/BasePConfig.php similarity index 62% rename from src/Core/Config/PConfiguration.php rename to src/Core/BasePConfig.php index ee90be3225..97eca70f7b 100644 --- a/src/Core/Config/PConfiguration.php +++ b/src/Core/BasePConfig.php @@ -1,7 +1,9 @@ configCache = $configCache; $this->configModel = $configModel; @@ -36,7 +38,7 @@ abstract class PConfiguration implements IPConfiguration /** * Returns the Config Cache * - * @return Cache\PConfigCache + * @return Cache */ public function getCache() { diff --git a/src/Core/Config/Cache/ConfigCache.php b/src/Core/Config/Cache.php similarity index 98% rename from src/Core/Config/Cache/ConfigCache.php rename to src/Core/Config/Cache.php index 3119b5db12..a6cb8d9fb1 100644 --- a/src/Core/Config/Cache/ConfigCache.php +++ b/src/Core/Config/Cache.php @@ -1,6 +1,6 @@ db_loaded = []; diff --git a/src/Core/Config/PreloadConfig.php b/src/Core/Config/PreloadConfig.php index 50ea9200f9..5b8350cd75 100644 --- a/src/Core/Config/PreloadConfig.php +++ b/src/Core/Config/PreloadConfig.php @@ -17,10 +17,10 @@ class PreloadConfig extends BaseConfig private $config_loaded; /** - * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files) + * @param Cache $configCache The configuration cache (based on the config-files) * @param Model\Config\Config $configModel The configuration model */ - public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel) + public function __construct(Cache $configCache, Model\Config\Config $configModel) { parent::__construct($configCache, $configModel); $this->config_loaded = false; diff --git a/src/Core/Installer.php b/src/Core/Installer.php index 01ef1d8c92..b780776cc1 100644 --- a/src/Core/Installer.php +++ b/src/Core/Installer.php @@ -6,7 +6,7 @@ namespace Friendica\Core; use DOMDocument; use Exception; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Database\Database; use Friendica\Database\DBStructure; use Friendica\DI; @@ -129,12 +129,12 @@ class Installer * - Creates `config/local.config.php` * - Installs Database Structure * - * @param ConfigCache $configCache The config cache with all config relevant information + * @param Cache $configCache The config cache with all config relevant information * * @return bool true if the config was created, otherwise false * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function createConfig(ConfigCache $configCache) + public function createConfig(Cache $configCache) { $basepath = $configCache->get('system', 'basepath'); @@ -618,12 +618,12 @@ class Installer /** * Setup the default cache for a new installation * - * @param ConfigCache $configCache The configuration cache - * @param string $basePath The determined basepath + * @param Cache $configCache The configuration cache + * @param string $basePath The determined basepath * * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public function setUpCache(ConfigCache $configCache, $basePath) + public function setUpCache(Cache $configCache, $basePath) { $configCache->set('config', 'php_path' , $this->getPHPPath()); $configCache->set('system', 'basepath' , $basePath); diff --git a/src/Core/Config/Cache/PConfigCache.php b/src/Core/PConfig/Cache.php similarity index 98% rename from src/Core/Config/Cache/PConfigCache.php rename to src/Core/PConfig/Cache.php index b0dd209cbf..5dc399e3a0 100644 --- a/src/Core/Config/Cache/PConfigCache.php +++ b/src/Core/PConfig/Cache.php @@ -1,13 +1,13 @@ db_loaded = []; diff --git a/src/Core/Config/PreloadPConfiguration.php b/src/Core/PConfig/PreloadPConfig.php similarity index 91% rename from src/Core/Config/PreloadPConfiguration.php rename to src/Core/PConfig/PreloadPConfig.php index 975a15c50f..e53fd97419 100644 --- a/src/Core/Config/PreloadPConfiguration.php +++ b/src/Core/PConfig/PreloadPConfig.php @@ -1,7 +1,8 @@ config_loaded = []; diff --git a/src/DI.php b/src/DI.php index 1109b1afb3..22c81079b9 100644 --- a/src/DI.php +++ b/src/DI.php @@ -141,11 +141,11 @@ abstract class DI } /** - * @return Core\Config\IPConfiguration + * @return \Friendica\Core\PConfig\IPConfig */ public static function pConfig() { - return self::$dice->create(Core\Config\IPConfiguration::class); + return self::$dice->create(Core\PConfig\IPConfig::class); } /** diff --git a/src/Database/Database.php b/src/Database/Database.php index 3afbfbc8f2..8a893ab935 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -2,7 +2,7 @@ namespace Friendica\Database; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\System; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\DateTimeFormat; @@ -25,7 +25,7 @@ class Database protected $connected = false; /** - * @var ConfigCache + * @var Cache */ protected $configCache; /** @@ -47,7 +47,7 @@ class Database protected $in_retrial = false; private $relation = []; - public function __construct(ConfigCache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = []) + public function __construct(Cache $configCache, Profiler $profiler, LoggerInterface $logger, array $server = []) { // We are storing these values for being able to perform a reconnect $this->configCache = $configCache; diff --git a/src/Factory/ConfigFactory.php b/src/Factory/ConfigFactory.php index f912399345..585d6eb7ee 100644 --- a/src/Factory/ConfigFactory.php +++ b/src/Factory/ConfigFactory.php @@ -13,23 +13,23 @@ class ConfigFactory /** * @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig) * - * @return Cache\ConfigCache + * @return Cache */ public function createCache(ConfigFileLoader $loader) { - $configCache = new Cache\ConfigCache(); + $configCache = new Cache(); $loader->setupCache($configCache); return $configCache; } /** - * @param Cache\ConfigCache $configCache The config cache of this adapter - * @param ConfigModel $configModel The configuration model + * @param Cache $configCache The config cache of this adapter + * @param ConfigModel $configModel The configuration model * * @return Config\IConfig */ - public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel) + public function createConfig(Cache $configCache, ConfigModel $configModel) { if ($configCache->get('system', 'config_adapter') === 'preload') { $configuration = new Config\PreloadConfig($configCache, $configModel); @@ -42,18 +42,18 @@ class ConfigFactory } /** - * @param Cache\ConfigCache $configCache The config cache - * @param Cache\PConfigCache $pConfigCache The personal config cache - * @param PConfigModel $configModel The configuration model + * @param Cache $configCache The config cache + * @param \Friendica\Core\PConfig\Cache $pConfigCache The personal config cache + * @param PConfigModel $configModel The configuration model * - * @return Config\IPConfiguration + * @return \Friendica\Core\PConfig\IPConfig */ - public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel) + public function createPConfig(Cache $configCache, \Friendica\Core\PConfig\Cache $pConfigCache, PConfigModel $configModel) { if ($configCache->get('system', 'config_adapter') === 'preload') { - $configuration = new Config\PreloadPConfiguration($pConfigCache, $configModel); + $configuration = new \Friendica\Core\PConfig\PreloadPConfig($pConfigCache, $configModel); } else { - $configuration = new Config\JitPConfiguration($pConfigCache, $configModel); + $configuration = new \Friendica\Core\PConfig\JitPConfig($pConfigCache, $configModel); } return $configuration; diff --git a/src/Model/Notify.php b/src/Model/Notify.php index 9912f5dffb..a27635a07e 100644 --- a/src/Model/Notify.php +++ b/src/Model/Notify.php @@ -6,7 +6,7 @@ use Exception; use Friendica\App; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; -use Friendica\Core\Config\IPConfiguration; +use Friendica\Core\PConfig\IPConfig; use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\System; @@ -71,13 +71,13 @@ final class Notify private $args; /** @var App\BaseURL */ private $baseUrl; - /** @var IPConfiguration */ + /** @var IPConfig */ private $pConfig; /** @var LoggerInterface */ private $logger; public function __construct(Database $dba, L10n $l10n, App\Arguments $args, App\BaseURL $baseUrl, - IPConfiguration $pConfig, LoggerInterface $logger) + IPConfig $pConfig, LoggerInterface $logger) { $this->dba = $dba; $this->l10n = $l10n; diff --git a/src/Module/Admin/Summary.php b/src/Module/Admin/Summary.php index c74f877268..e5adc27186 100644 --- a/src/Module/Admin/Summary.php +++ b/src/Module/Admin/Summary.php @@ -110,7 +110,7 @@ class Summary extends BaseAdminModule // check legacy basepath settings $configLoader = new ConfigFileLoader($a->getBasePath()); - $configCache = new Config\Cache\ConfigCache(); + $configCache = new Config\Cache(); $configLoader->setupCache($configCache); $confBasepath = $configCache->get('system', 'basepath'); $currBasepath = DI::config()->get('system', 'basepath'); diff --git a/src/Module/Install.php b/src/Module/Install.php index e20d80f205..392adaab1b 100644 --- a/src/Module/Install.php +++ b/src/Module/Install.php @@ -5,7 +5,7 @@ namespace Friendica\Module; use Friendica\App; use Friendica\BaseModule; use Friendica\Core; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Network\HTTPException; @@ -332,13 +332,13 @@ class Install extends BaseModule /** * Checks the $_POST settings and updates the config Cache for it * - * @param ConfigCache $configCache The current config cache + * @param Cache $configCache The current config cache * @param array $post The $_POST data * @param string $cat The category of the setting * @param string $key The key of the setting * @param null|string $default The default value */ - private static function checkSetting(ConfigCache $configCache, array $post, $cat, $key, $default = null) + private static function checkSetting(Cache $configCache, array $post, $cat, $key, $default = null) { $configCache->set($cat, $key, Strings::escapeTags( diff --git a/src/Util/ConfigFileLoader.php b/src/Util/ConfigFileLoader.php index 80da4018c0..5acf4630d8 100644 --- a/src/Util/ConfigFileLoader.php +++ b/src/Util/ConfigFileLoader.php @@ -4,10 +4,10 @@ namespace Friendica\Util; use Exception; use Friendica\Core\Addon; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; /** - * The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache ) + * The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see Cache ) * * It is capable of loading the following config files: * - *.config.php (current) @@ -77,12 +77,12 @@ class ConfigFileLoader * First loads the default value for all the configuration keys, then the legacy configuration files, then the * expected local.config.php * - * @param ConfigCache $config The config cache to load to - * @param bool $raw Setup the raw config format + * @param Cache $config The config cache to load to + * @param bool $raw Setup the raw config format * * @throws Exception */ - public function setupCache(ConfigCache $config, $raw = false) + public function setupCache(Cache $config, $raw = false) { // Load static config files first, the order is important $config->load($this->loadStaticConfig('defaults')); @@ -128,13 +128,13 @@ class ConfigFileLoader /** * Tries to load the specified core-configuration into the config cache. * - * @param ConfigCache $config The Config cache + * @param Cache $config The Config cache * * @return array The config array (empty if no config found) * * @throws Exception if the configuration file isn't readable */ - private function loadCoreConfig(ConfigCache $config) + private function loadCoreConfig(Cache $config) { // try to load legacy ini-files first foreach ($this->getConfigFiles(true) as $configFile) { diff --git a/src/Util/Profiler.php b/src/Util/Profiler.php index e4061f5194..c3fddfac70 100644 --- a/src/Util/Profiler.php +++ b/src/Util/Profiler.php @@ -2,7 +2,7 @@ namespace Friendica\Util; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Config\IConfig; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; @@ -56,9 +56,9 @@ class Profiler implements ContainerInterface } /** - * @param ConfigCache $configCache The configuration cache + * @param Cache $configCache The configuration cache */ - public function __construct(ConfigCache $configCache) + public function __construct(Cache $configCache) { $this->enabled = $configCache->get('system', 'profiler'); $this->rendertime = $configCache->get('rendertime', 'callstack'); diff --git a/static/dependencies.config.php b/static/dependencies.config.php index cf2d6dd3ff..51fff62289 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -48,43 +48,43 @@ return [ $_SERVER ] ], - Util\BasePath::class => [ + Util\BasePath::class => [ 'constructParams' => [ dirname(__FILE__, 2), $_SERVER ] ], - Util\ConfigFileLoader::class => [ + Util\ConfigFileLoader::class => [ 'shared' => true, 'constructParams' => [ [Dice::INSTANCE => '$basepath'], ], ], - Config\Cache\ConfigCache::class => [ + Config\Cache::class => [ 'instanceOf' => Factory\ConfigFactory::class, 'call' => [ ['createCache', [], Dice::CHAIN_CALL], ], ], - App\Mode::class => [ + App\Mode::class => [ 'call' => [ ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL], ['determine', [], Dice::CHAIN_CALL], ], ], - Config\IConfig::class => [ + Config\IConfig::class => [ 'instanceOf' => Factory\ConfigFactory::class, 'call' => [ ['createConfig', [], Dice::CHAIN_CALL], ], ], - Config\IPConfiguration::class => [ + \Friendica\Core\PConfig\IPConfig::class => [ 'instanceOf' => Factory\ConfigFactory::class, 'call' => [ ['createPConfig', [], Dice::CHAIN_CALL], ] ], - Database::class => [ + Database::class => [ 'constructParams' => [ [Dice::INSTANCE => \Psr\Log\NullLogger::class], $_SERVER, diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index 353676932f..6e929e5f21 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -52,9 +52,9 @@ trait AppMockTrait $this->dice = \Mockery::mock(Dice::class)->makePartial(); $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php'); - $this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class); + $this->configMock = \Mockery::mock(Config\Cache::class); $this->dice->shouldReceive('create') - ->with(Config\Cache\ConfigCache::class) + ->with(Config\Cache::class) ->andReturn($this->configMock); $this->mode = \Mockery::mock(App\Mode::class); $this->dice->shouldReceive('create') diff --git a/tests/functional/DependencyCheckTest.php b/tests/functional/DependencyCheckTest.php index 468e967d65..944b623905 100644 --- a/tests/functional/DependencyCheckTest.php +++ b/tests/functional/DependencyCheckTest.php @@ -6,7 +6,7 @@ use Dice\Dice; use Friendica\App; use Friendica\Core\Cache\ICache; use Friendica\Core\Cache\IMemoryCache; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Config\IConfig; use Friendica\Core\Lock\ILock; use Friendica\Database\Database; @@ -59,7 +59,7 @@ class dependencyCheck extends TestCase $this->assertInstanceOf(ConfigFileLoader::class, $configFileLoader); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); $this->assertNotEmpty($configCache->getAll()); @@ -77,7 +77,7 @@ class dependencyCheck extends TestCase $this->assertInstanceOf(Profiler::class, $profiler); - $configCache = new ConfigCache([ + $configCache = new Cache([ 'system' => [ 'profiler' => true, ], diff --git a/tests/include/ApiTest.php b/tests/include/ApiTest.php index 5180d3b36d..466248f652 100644 --- a/tests/include/ApiTest.php +++ b/tests/include/ApiTest.php @@ -8,7 +8,7 @@ namespace Friendica\Test; use Dice\Dice; use Friendica\App; use Friendica\Core\Config\IConfig; -use Friendica\Core\Config\IPConfiguration; +use Friendica\Core\PConfig\IPConfig; use Friendica\Core\Protocol; use Friendica\Core\Session; use Friendica\Core\Session\ISession; @@ -827,7 +827,7 @@ class ApiTest extends DatabaseTest */ public function testApiGetUserWithFrioSchema() { - $pConfig = $this->dice->create(IPConfiguration::class); + $pConfig = $this->dice->create(IPConfig::class); $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red'); $user = api_get_user($this->app); $this->assertSelfUser($user); @@ -843,7 +843,7 @@ class ApiTest extends DatabaseTest */ public function testApiGetUserWithCustomFrioSchema() { - $pConfig = $this->dice->create(IPConfiguration::class); + $pConfig = $this->dice->create(IPConfig::class); $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---'); $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456'); $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456'); @@ -862,7 +862,7 @@ class ApiTest extends DatabaseTest */ public function testApiGetUserWithEmptyFrioSchema() { - $pConfig = $this->dice->create(IPConfiguration::class); + $pConfig = $this->dice->create(IPConfig::class); $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---'); $user = api_get_user($this->app); $this->assertSelfUser($user); diff --git a/tests/src/App/ModeTest.php b/tests/src/App/ModeTest.php index 12ec2b4db8..2fbb6863c0 100644 --- a/tests/src/App/ModeTest.php +++ b/tests/src/App/ModeTest.php @@ -29,7 +29,7 @@ class ModeTest extends MockedTest private $databaseMock; /** - * @var Config\Cache\ConfigCache|MockInterface + * @var \Friendica\Core\Config\Cache|MockInterface */ private $configCacheMock; @@ -41,7 +41,7 @@ class ModeTest extends MockedTest $this->basePathMock = \Mockery::mock(BasePath::class); $this->databaseMock = \Mockery::mock(Database::class); - $this->configCacheMock = \Mockery::mock(Config\Cache\ConfigCache::class); + $this->configCacheMock = \Mockery::mock(Config\Cache::class); } public function testItEmpty() diff --git a/tests/src/Console/AutomaticInstallationConsoleTest.php b/tests/src/Console/AutomaticInstallationConsoleTest.php index ab879b3194..ed31661673 100644 --- a/tests/src/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Console/AutomaticInstallationConsoleTest.php @@ -5,7 +5,7 @@ namespace Friendica\Test\src\Console; use Dice\Dice; use Friendica\App; use Friendica\Console\AutomaticInstallation; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Installer; use Friendica\Core\L10n; use Friendica\Core\Logger; @@ -37,7 +37,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest private $assertFileDb; /** - * @var ConfigCache The configuration cache to check after each test + * @var Cache The configuration cache to check after each test */ private $configCache; @@ -79,7 +79,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest DI::init($this->dice); - $this->configCache = new ConfigCache(); + $this->configCache = new Cache(); $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'); diff --git a/tests/src/Core/Config/Cache/ConfigCacheTest.php b/tests/src/Core/Config/Cache/ConfigCacheTest.php index d8ac3eaea4..6d0b045db4 100644 --- a/tests/src/Core/Config/Cache/ConfigCacheTest.php +++ b/tests/src/Core/Config/Cache/ConfigCacheTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Core\Config\Cache; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Test\MockedTest; use ParagonIE\HiddenString\HiddenString; @@ -29,7 +29,7 @@ class ConfigCacheTest extends MockedTest ]; } - private function assertConfigValues($data, ConfigCache $configCache) + private function assertConfigValues($data, Cache $configCache) { foreach ($data as $cat => $values) { foreach ($values as $key => $value) { @@ -44,7 +44,7 @@ class ConfigCacheTest extends MockedTest */ public function testLoadConfigArray($data) { - $configCache = new ConfigCache(); + $configCache = new Cache(); $configCache->load($data); $this->assertConfigValues($data, $configCache); @@ -63,7 +63,7 @@ class ConfigCacheTest extends MockedTest ] ]; - $configCache = new ConfigCache(); + $configCache = new Cache(); $configCache->load($data); $configCache->load($override); @@ -81,7 +81,7 @@ class ConfigCacheTest extends MockedTest */ public function testLoadConfigArrayWrong() { - $configCache = new ConfigCache(); + $configCache = new Cache(); // empty dataset $configCache->load([]); @@ -102,7 +102,7 @@ class ConfigCacheTest extends MockedTest */ public function testGetAll($data) { - $configCache = new ConfigCache(); + $configCache = new Cache(); $configCache->load($data); $all = $configCache->getAll(); @@ -117,7 +117,7 @@ class ConfigCacheTest extends MockedTest */ public function testSetGet($data) { - $configCache = new ConfigCache(); + $configCache = new Cache(); foreach ($data as $cat => $values) { foreach ($values as $key => $value) { @@ -133,7 +133,7 @@ class ConfigCacheTest extends MockedTest */ public function testGetEmpty() { - $configCache = new ConfigCache(); + $configCache = new Cache(); $this->assertNull($configCache->get('something', 'value')); } @@ -143,7 +143,7 @@ class ConfigCacheTest extends MockedTest */ public function testGetCat() { - $configCache = new ConfigCache([ + $configCache = new Cache([ 'system' => [ 'key1' => 'value1', 'key2' => 'value2', @@ -171,7 +171,7 @@ class ConfigCacheTest extends MockedTest */ public function testDelete($data) { - $configCache = new ConfigCache($data); + $configCache = new Cache($data); foreach ($data as $cat => $values) { foreach ($values as $key => $value) { @@ -188,7 +188,7 @@ class ConfigCacheTest extends MockedTest */ public function testKeyDiffWithResult($data) { - $configCache = new ConfigCache($data); + $configCache = new Cache($data); $diffConfig = [ 'fakeCat' => [ @@ -205,7 +205,7 @@ class ConfigCacheTest extends MockedTest */ public function testKeyDiffWithoutResult($data) { - $configCache = new ConfigCache($data); + $configCache = new Cache($data); $diffConfig = $configCache->getAll(); @@ -217,7 +217,7 @@ class ConfigCacheTest extends MockedTest */ public function testPasswordHide() { - $configCache = new ConfigCache([ + $configCache = new Cache([ 'database' => [ 'password' => 'supersecure', 'username' => 'notsecured', @@ -234,7 +234,7 @@ class ConfigCacheTest extends MockedTest */ public function testPasswordShow() { - $configCache = new ConfigCache([ + $configCache = new Cache([ 'database' => [ 'password' => 'supersecure', 'username' => 'notsecured', @@ -251,7 +251,7 @@ class ConfigCacheTest extends MockedTest */ public function testEmptyPassword() { - $configCache = new ConfigCache([ + $configCache = new Cache([ 'database' => [ 'password' => '', 'username' => '', @@ -265,7 +265,7 @@ class ConfigCacheTest extends MockedTest public function testWrongTypePassword() { - $configCache = new ConfigCache([ + $configCache = new Cache([ 'database' => [ 'password' => new \stdClass(), 'username' => '', @@ -275,7 +275,7 @@ class ConfigCacheTest extends MockedTest $this->assertNotEmpty($configCache->get('database', 'password')); $this->assertEmpty($configCache->get('database', 'username')); - $configCache = new ConfigCache([ + $configCache = new Cache([ 'database' => [ 'password' => 23, 'username' => '', diff --git a/tests/src/Core/Config/Cache/PConfigCacheTest.php b/tests/src/Core/Config/Cache/PConfigCacheTest.php index 283a5bc6ab..1d5a96f695 100644 --- a/tests/src/Core/Config/Cache/PConfigCacheTest.php +++ b/tests/src/Core/Config/Cache/PConfigCacheTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Core\Config\Cache; -use Friendica\Core\Config\Cache\PConfigCache; +use Friendica\Core\PConfig\Cache; use Friendica\Test\MockedTest; class PConfigCacheTest extends MockedTest @@ -28,7 +28,7 @@ class PConfigCacheTest extends MockedTest ]; } - private function assertConfigValues($data, PConfigCache $configCache, $uid) + private function assertConfigValues($data, Cache $configCache, $uid) { foreach ($data as $cat => $values) { foreach ($values as $key => $value) { @@ -44,7 +44,7 @@ class PConfigCacheTest extends MockedTest */ public function testSetGet($data) { - $configCache = new PConfigCache(); + $configCache = new Cache(); $uid = 345; foreach ($data as $cat => $values) { @@ -62,7 +62,7 @@ class PConfigCacheTest extends MockedTest */ public function testGetCat() { - $configCache = new PConfigCache(); + $configCache = new Cache(); $uid = 345; $configCache->load($uid, [ @@ -94,7 +94,7 @@ class PConfigCacheTest extends MockedTest */ public function testDelete($data) { - $configCache = new PConfigCache(); + $configCache = new Cache(); $uid = 345; foreach ($data as $cat => $values) { @@ -119,7 +119,7 @@ class PConfigCacheTest extends MockedTest */ public function testKeyDiffWithResult($data) { - $configCache = new PConfigCache(); + $configCache = new Cache(); $diffConfig = [ 'fakeCat' => [ @@ -137,7 +137,7 @@ class PConfigCacheTest extends MockedTest */ public function testKeyDiffWithoutResult($data) { - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, $data); @@ -151,7 +151,7 @@ class PConfigCacheTest extends MockedTest */ public function testPasswordHide() { - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, [ 'database' => [ @@ -170,7 +170,7 @@ class PConfigCacheTest extends MockedTest */ public function testPasswordShow() { - $configCache = new PConfigCache(false); + $configCache = new Cache(false); $configCache->load(1, [ 'database' => [ @@ -189,7 +189,7 @@ class PConfigCacheTest extends MockedTest */ public function testEmptyPassword() { - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, [ 'database' => [ @@ -204,7 +204,7 @@ class PConfigCacheTest extends MockedTest public function testWrongTypePassword() { - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, [ 'database' => [ @@ -216,7 +216,7 @@ class PConfigCacheTest extends MockedTest $this->assertNotEmpty($configCache->get(1, 'database', 'password')); $this->assertEmpty($configCache->get(1, 'database', 'username')); - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, [ 'database' => [ @@ -234,7 +234,7 @@ class PConfigCacheTest extends MockedTest */ public function testTwoUid() { - $configCache = new PConfigCache(); + $configCache = new Cache(); $configCache->load(1, [ 'cat1' => [ @@ -265,7 +265,7 @@ class PConfigCacheTest extends MockedTest // bad UID! $uid = null; - $configCache = new PConfigCache(); + $configCache = new Cache(); $this->assertNull($configCache->get($uid, 'cat1', 'cat2')); diff --git a/tests/src/Core/Config/ConfigurationTest.php b/tests/src/Core/Config/ConfigurationTest.php index 4090407aea..b36d0ac31e 100644 --- a/tests/src/Core/Config/ConfigurationTest.php +++ b/tests/src/Core/Config/ConfigurationTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Config\IConfig; use Friendica\Model\Config\Config as ConfigModel; use Friendica\Test\MockedTest; @@ -14,7 +14,7 @@ abstract class ConfigurationTest extends MockedTest /** @var ConfigModel|MockInterface */ protected $configModel; - /** @var ConfigCache */ + /** @var Cache */ protected $configCache; /** @var IConfig */ @@ -42,7 +42,7 @@ abstract class ConfigurationTest extends MockedTest // Create the config model $this->configModel = Mockery::mock(ConfigModel::class); - $this->configCache = new ConfigCache(); + $this->configCache = new Cache(); } /** @@ -142,7 +142,7 @@ abstract class ConfigurationTest extends MockedTest ->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // assert config is loaded everytime $this->assertConfig('config', $data['config']); @@ -154,7 +154,7 @@ abstract class ConfigurationTest extends MockedTest public function testLoad(array $data, array $possibleCats, array $load) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); foreach ($load as $loadedCats) { $this->testedConfig->load($loadedCats); @@ -235,7 +235,7 @@ abstract class ConfigurationTest extends MockedTest public function testCacheLoadDouble(array $data1, array $data2, array $expect) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); foreach ($data1 as $cat => $data) { $this->testedConfig->load($cat); @@ -260,7 +260,7 @@ abstract class ConfigurationTest extends MockedTest $this->configModel->shouldReceive('load')->withAnyArgs()->andReturn([])->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertEmpty($this->testedConfig->getCache()->getAll()); } @@ -277,7 +277,7 @@ abstract class ConfigurationTest extends MockedTest ->times(3); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertTrue($this->testedConfig->set('test', 'it', $data)); @@ -295,7 +295,7 @@ abstract class ConfigurationTest extends MockedTest $this->configModel->shouldReceive('set')->with('test', 'it', $data)->andReturn(true)->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertTrue($this->testedConfig->set('test', 'it', $data)); @@ -309,7 +309,7 @@ abstract class ConfigurationTest extends MockedTest public function testGetWrongWithoutDB() { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // without refresh $this->assertNull($this->testedConfig->get('test', 'it')); @@ -334,7 +334,7 @@ abstract class ConfigurationTest extends MockedTest $this->configCache->load(['test' => ['it' => 'now']]); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // without refresh $this->assertEquals('now', $this->testedConfig->get('test', 'it')); @@ -359,7 +359,7 @@ abstract class ConfigurationTest extends MockedTest $this->configCache->load(['test' => ['it' => $data]]); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertEquals($data, $this->testedConfig->get('test', 'it')); $this->assertEquals($data, $this->testedConfig->getCache()->get('test', 'it')); @@ -396,7 +396,7 @@ abstract class ConfigurationTest extends MockedTest ->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(ConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // directly set the value to the cache $this->testedConfig->getCache()->set('test', 'it', 'now'); diff --git a/tests/src/Core/Config/JitPConfigurationTest.php b/tests/src/Core/Config/JitPConfigurationTest.php index 8ceea93ff4..c45584f137 100644 --- a/tests/src/Core/Config/JitPConfigurationTest.php +++ b/tests/src/Core/Config/JitPConfigurationTest.php @@ -2,13 +2,13 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\JitPConfiguration; +use Friendica\Core\PConfig\JitPConfig; class JitPConfigurationTest extends PConfigurationTest { public function getInstance() { - return new JitPConfiguration($this->configCache, $this->configModel); + return new JitPConfig($this->configCache, $this->configModel); } /** diff --git a/tests/src/Core/Config/PConfigurationTest.php b/tests/src/Core/Config/PConfigurationTest.php index 40c6970a5c..c8429b2d00 100644 --- a/tests/src/Core/Config/PConfigurationTest.php +++ b/tests/src/Core/Config/PConfigurationTest.php @@ -2,8 +2,8 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\Cache\PConfigCache; -use Friendica\Core\Config\PConfiguration; +use Friendica\Core\PConfig\Cache; +use Friendica\Core\BasePConfig; use Friendica\Model\Config\PConfig as PConfigModel; use Friendica\Test\MockedTest; use Mockery; @@ -14,10 +14,10 @@ abstract class PConfigurationTest extends MockedTest /** @var PConfigModel|MockInterface */ protected $configModel; - /** @var PConfigCache */ + /** @var Cache */ protected $configCache; - /** @var PConfiguration */ + /** @var BasePConfig */ protected $testedConfig; /** @@ -44,11 +44,11 @@ abstract class PConfigurationTest extends MockedTest // Create the config model $this->configModel = Mockery::mock(PConfigModel::class); - $this->configCache = new PConfigCache(); + $this->configCache = new Cache(); } /** - * @return PConfiguration + * @return BasePConfig */ public abstract function getInstance(); @@ -145,7 +145,7 @@ abstract class PConfigurationTest extends MockedTest public function testSetUp(int $uid, array $data) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertEmpty($this->testedConfig->getCache()->getAll()); } @@ -156,7 +156,7 @@ abstract class PConfigurationTest extends MockedTest public function testLoad(int $uid, array $data, array $possibleCats, array $load) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); foreach ($load as $loadedCats) { $this->testedConfig->load($uid, $loadedCats); @@ -239,7 +239,7 @@ abstract class PConfigurationTest extends MockedTest public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); foreach ($data1 as $cat => $data) { $this->testedConfig->load($uid, $cat); @@ -263,7 +263,7 @@ abstract class PConfigurationTest extends MockedTest public function testSetGetWithoutDB(int $uid, $data) { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data)); @@ -284,7 +284,7 @@ abstract class PConfigurationTest extends MockedTest ->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertTrue($this->testedConfig->set($uid, 'test', 'it', $data)); @@ -298,7 +298,7 @@ abstract class PConfigurationTest extends MockedTest public function testGetWrongWithoutDB() { $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // without refresh $this->assertNull($this->testedConfig->get(0, 'test', 'it')); @@ -323,7 +323,7 @@ abstract class PConfigurationTest extends MockedTest $this->configCache->load($uid, ['test' => ['it' => 'now']]); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // without refresh $this->assertEquals('now', $this->testedConfig->get($uid, 'test', 'it')); @@ -348,7 +348,7 @@ abstract class PConfigurationTest extends MockedTest $this->configCache->load($uid, ['test' => ['it' => $data]]); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertEquals($data, $this->testedConfig->get($uid, 'test', 'it')); $this->assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it')); @@ -387,7 +387,7 @@ abstract class PConfigurationTest extends MockedTest ->once(); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); // directly set the value to the cache $this->testedConfig->getCache()->set($uid, 'test', 'it', 'now'); @@ -447,7 +447,7 @@ abstract class PConfigurationTest extends MockedTest $this->configCache->load($data2['uid'], $data2['data']); $this->testedConfig = $this->getInstance(); - $this->assertInstanceOf(PConfigCache::class, $this->testedConfig->getCache()); + $this->assertInstanceOf(Cache::class, $this->testedConfig->getCache()); $this->assertConfig($data1['uid'], 'cat1', $data1['data']['cat1']); $this->assertConfig($data1['uid'], 'cat2', $data1['data']['cat2']); diff --git a/tests/src/Core/Config/PreloadPConfigurationTest.php b/tests/src/Core/Config/PreloadPConfigurationTest.php index 270a7a2e0b..79d0d49db3 100644 --- a/tests/src/Core/Config/PreloadPConfigurationTest.php +++ b/tests/src/Core/Config/PreloadPConfigurationTest.php @@ -2,13 +2,13 @@ namespace Friendica\Test\src\Core\Config; -use Friendica\Core\Config\PreloadPConfiguration; +use Friendica\Core\PConfig\PreloadPConfig; class PreloadPConfigurationTest extends PConfigurationTest { public function getInstance() { - return new PreloadPConfiguration($this->configCache, $this->configModel); + return new PreloadPConfig($this->configCache, $this->configModel); } /** diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php index abc2087638..371932caf2 100644 --- a/tests/src/Core/InstallerTest.php +++ b/tests/src/Core/InstallerTest.php @@ -4,7 +4,7 @@ namespace Friendica\Core; use Dice\Dice; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\DI; use Friendica\Network\CurlResult; use Friendica\Test\MockedTest; @@ -419,7 +419,7 @@ class InstallerTest extends MockedTest $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); $install = new Installer(); - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('set')->with('config', 'php_path', \Mockery::any())->once(); $configCache->shouldReceive('set')->with('system', 'basepath', '/test/')->once(); diff --git a/tests/src/Util/Config/ConfigFileLoaderTest.php b/tests/src/Util/Config/ConfigFileLoaderTest.php index aa9a11cb08..59b2f39cb0 100644 --- a/tests/src/Util/Config/ConfigFileLoaderTest.php +++ b/tests/src/Util/Config/ConfigFileLoaderTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Util\Config; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Test\MockedTest; use Friendica\Test\Util\VFSTrait; use Friendica\Util\ConfigFileLoader; @@ -27,7 +27,7 @@ class ConfigFileLoaderTest extends MockedTest $this->delConfigFile('local.config.php'); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -48,7 +48,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent('root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); } @@ -72,7 +72,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($file)); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -104,7 +104,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($file)); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -135,7 +135,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($file)); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -216,7 +216,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($fileDir . 'B.config.php')); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -245,7 +245,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($fileDir . 'B.ini.php')); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); @@ -274,7 +274,7 @@ class ConfigFileLoaderTest extends MockedTest ->setContent(file_get_contents($fileDir . 'B.ini.php')); $configFileLoader = new ConfigFileLoader($this->root->url()); - $configCache = new ConfigCache(); + $configCache = new Cache(); $configFileLoader->setupCache($configCache); diff --git a/tests/src/Util/ProfilerTest.php b/tests/src/Util/ProfilerTest.php index 400d557c34..cfd28af174 100644 --- a/tests/src/Util/ProfilerTest.php +++ b/tests/src/Util/ProfilerTest.php @@ -2,7 +2,7 @@ namespace Friendica\Test\src\Util; -use Friendica\Core\Config\Cache\ConfigCache; +use Friendica\Core\Config\Cache; use Friendica\Core\Config\IConfig; use Friendica\Test\MockedTest; use Friendica\Util\Profiler; @@ -28,7 +28,7 @@ class ProfilerTest extends MockedTest */ public function testSetUp() { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -103,7 +103,7 @@ class ProfilerTest extends MockedTest */ public function testSaveTimestamp($timestamp, $name, array $functions) { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -124,7 +124,7 @@ class ProfilerTest extends MockedTest */ public function testReset($timestamp, $name, array $functions) { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -187,7 +187,7 @@ class ProfilerTest extends MockedTest ->shouldReceive('info') ->once(); - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->withAnyArgs() ->andReturn(true) @@ -218,7 +218,7 @@ class ProfilerTest extends MockedTest */ public function testEnableDisable() { - $configCache = \Mockery::mock(ConfigCache::class); + $configCache = \Mockery::mock(Cache::class); $configCache->shouldReceive('get') ->with('system', 'profiler') ->andReturn(true) -- 2.39.5