]> git.mxchange.org Git - friendica.git/commitdiff
Creating interfaces for Config/PConfig & fix tests
authornupplaPhil <admin@philipp.info>
Thu, 19 Dec 2019 19:11:07 +0000 (20:11 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 29 Dec 2019 19:18:19 +0000 (20:18 +0100)
54 files changed:
index.php
src/App.php
src/App/Authentication.php
src/App/BaseURL.php
src/App/Module.php
src/App/Page.php
src/Console/AutomaticInstallation.php
src/Console/Config.php
src/Console/Maintenance.php
src/Console/PostUpdate.php
src/Console/ServerBlock.php
src/Console/Typo.php
src/Core/Cache/MemcacheCache.php
src/Core/Cache/MemcachedCache.php
src/Core/Cache/RedisCache.php
src/Core/Config/Configuration.php
src/Core/Config/IConfiguration.php [new file with mode: 0644]
src/Core/Config/IPConfiguration.php [new file with mode: 0644]
src/Core/Config/PConfiguration.php
src/Core/L10n/L10n.php
src/Core/Process.php
src/DI.php
src/Factory/CacheFactory.php
src/Factory/ConfigFactory.php
src/Factory/LockFactory.php
src/Factory/LoggerFactory.php
src/Factory/SessionFactory.php
src/Model/Notify.php
src/Model/User/Cookie.php
src/Module/Diaspora/Receive.php
src/Util/Profiler.php
static/dependencies.config.php
tests/Util/AppMockTrait.php
tests/bootstrap.php
tests/functional/DependencyCheckTest.php
tests/include/ApiTest.php
tests/phpunit-local.xml [new file with mode: 0644]
tests/src/App/ModuleTest.php
tests/src/Console/ConfigConsoleTest.php
tests/src/Console/ServerBlockConsoleTest.php
tests/src/Content/Text/BBCodeTest.php
tests/src/Core/Cache/MemcacheCacheTest.php
tests/src/Core/Cache/MemcachedCacheTest.php
tests/src/Core/Cache/RedisCacheTest.php
tests/src/Core/Config/ConfigurationTest.php
tests/src/Core/InstallerTest.php
tests/src/Core/Lock/MemcacheCacheLockTest.php
tests/src/Core/Lock/MemcachedCacheLockTest.php
tests/src/Core/Lock/RedisCacheLockTest.php
tests/src/Core/Lock/SemaphoreLockTest.php
tests/src/Model/User/CookieTest.php
tests/src/Network/CurlResultTest.php
tests/src/Util/BaseURLTest.php
tests/src/Util/ProfilerTest.php

index b558e86c8e83a3b6c6fe981529a8f06fa0ec12cc..8400ca820ff756140b3f48db9f906c8fe1d9faf6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -22,6 +22,6 @@ $a = \Friendica\DI::app();
 $a->runFrontend(
        $dice->create(\Friendica\App\Module::class),
        $dice->create(\Friendica\App\Router::class),
-       $dice->create(\Friendica\Core\Config\PConfiguration::class),
+       $dice->create(\Friendica\Core\Config\IPConfiguration::class),
        $dice->create(\Friendica\App\Authentication::class)
 );
index 75fa4f197b0efb80aa4c24e078993bd7b20e9a52..71b64bdb64781a899c257cf7d10ba9f94fd39b3b 100644 (file)
@@ -10,8 +10,8 @@ use Friendica\App\BaseURL;
 use Friendica\App\Page;
 use Friendica\App\Authentication;
 use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
 use Friendica\Core\L10n\L10n;
 use Friendica\Core\System;
 use Friendica\Core\Theme;
@@ -88,7 +88,7 @@ class App
        private $currentMobileTheme;
 
        /**
-        * @var Configuration The config
+        * @var IConfiguration The config
         */
        private $config;
 
@@ -145,7 +145,7 @@ class App
 
        /**
         * @param Database        $database The Friendica Database
-        * @param Configuration   $config   The Configuration
+        * @param IConfiguration   $config   The Configuration
         * @param App\Mode        $mode     The mode of this Friendica app
         * @param BaseURL         $baseURL  The full base URL of this Friendica app
         * @param LoggerInterface $logger   The current app logger
@@ -154,7 +154,7 @@ class App
         * @param App\Arguments   $args     The Friendica Arguments of the call
         * @param Core\Process    $process  The process methods
         */
-       public function __construct(Database $database, Configuration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Page $page, Core\Process $process)
+       public function __construct(Database $database, IConfiguration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Page $page, Core\Process $process)
        {
                $this->database = $database;
                $this->config   = $config;
@@ -433,12 +433,12 @@ class App
         *
         * @param App\Module     $module The determined module
         * @param App\Router     $router
-        * @param PConfiguration $pconfig
+        * @param IPConfiguration $pconfig
         * @param Authentication $auth The Authentication backend of the node
         * @throws HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public function runFrontend(App\Module $module, App\Router $router, PConfiguration $pconfig, Authentication $auth)
+       public function runFrontend(App\Module $module, App\Router $router, IPConfiguration $pconfig, Authentication $auth)
        {
                $moduleName = $module->getName();
 
index 22d429c76b8f5a3d48859b4435bc782e97f6f2df..cb07d7afc2734a371ccdf2f1416a7f0f3d1f3562 100644 (file)
@@ -8,7 +8,7 @@ namespace Friendica\App;
 
 use Exception;
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Hook;
 use Friendica\Core\PConfig;
 use Friendica\Core\Session;
@@ -30,7 +30,7 @@ use Psr\Log\LoggerInterface;
  */
 class Authentication
 {
-       /** @var Configuration */
+       /** @var IConfiguration */
        private $config;
        /** @var App\Mode */
        private $mode;
@@ -50,7 +50,7 @@ class Authentication
        /**
         * Authentication constructor.
         *
-        * @param Configuration   $config
+        * @param IConfiguration   $config
         * @param App\Mode        $mode
         * @param App\BaseURL     $baseUrl
         * @param L10n            $l10n
@@ -59,7 +59,7 @@ class Authentication
         * @param User\Cookie     $cookie
         * @param Session\ISession $session
         */
-       public function __construct(Configuration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
+       public function __construct(IConfiguration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
        {
                $this->config  = $config;
                $this->mode = $mode;
index 501e5fbd3bc32c6846554761e9fb225b1fa43aad..ea7d9ec74af351b0932025d77cd48073d6fc1c80 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Friendica\App;
 
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\System;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
@@ -37,7 +37,7 @@ class BaseURL
        /**
         * The Friendica Config
         *
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -253,10 +253,10 @@ class BaseURL
        }
 
        /**
-        * @param Configuration $config The Friendica configuration
+        * @param IConfiguration $config The Friendica IConfiguration
         * @param array         $server The $_SERVER array
         */
-       public function __construct(Configuration $config, array $server)
+       public function __construct(IConfiguration $config, array $server)
        {
                $this->config = $config;
                $this->server = $server;
index 51be234937d9bf19b329bba9f728f41b384b54ba..7c81b6a7eaac2a9797b6e4baf11367f8463313b0 100644 (file)
@@ -151,13 +151,13 @@ class Module
         *
         * @param Arguments                 $args   The Friendica execution arguments
         * @param Router                    $router The Friendica routing instance
-        * @param Core\Config\Configuration $config The Friendica Configuration
+        * @param Core\Config\IConfiguration $config The Friendica Configuration
         *
         * @return Module The determined module of this call
         *
         * @throws \Exception
         */
-       public function determineClass(Arguments $args, Router $router, Core\Config\Configuration $config)
+       public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config)
        {
                $printNotAllowedAddon = false;
 
index ca98bb6b2392cc118510ee3fad7ec98431e14a8f..5efb9f7ca3d64deae2f9fd1da93fce07964395d4 100644 (file)
@@ -7,8 +7,8 @@ use DOMDocument;
 use DOMXPath;
 use Friendica\App;
 use Friendica\Content\Nav;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n\L10n;
 use Friendica\Core\Renderer;
@@ -171,12 +171,12 @@ class Page implements ArrayAccess
         * @param App            $app     The Friendica App instance
         * @param Module         $module  The loaded Friendica module
         * @param L10n           $l10n    The l10n language instance
-        * @param Configuration  $config  The Friendica configuration
-        * @param PConfiguration $pConfig The Friendica personal configuration (for user)
+        * @param IConfiguration  $config  The Friendica configuration
+        * @param IPConfiguration $pConfig The Friendica personal configuration (for user)
         *
         * @throws HTTPException\InternalServerErrorException
         */
-       private function initHead(App $app, Module $module, L10n $l10n, Configuration $config, PConfiguration $pConfig)
+       private function initHead(App $app, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pConfig)
        {
                $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
 
@@ -347,12 +347,12 @@ class Page implements ArrayAccess
         * @param Mode           $mode    The current node mode
         * @param Module         $module  The loaded Friendica module
         * @param L10n           $l10n    The l10n language class
-        * @param Configuration  $config  The Configuration of this node
-        * @param PConfiguration $pconfig The personal/user configuration
+        * @param IConfiguration  $config  The Configuration of this node
+        * @param IPConfiguration $pconfig The personal/user configuration
         *
         * @throws HTTPException\InternalServerErrorException
         */
-       public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, Configuration $config, PConfiguration $pconfig)
+       public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pconfig)
        {
                $moduleName = $module->getName();
 
index 8815b98799fbb854ced93fc0d124c71b09f83cd1..1d378b9debaca75961884c559e458fc63f9a08d7 100644 (file)
@@ -25,7 +25,7 @@ class AutomaticInstallation extends Console
        private $configCache;
 
        /**
-        * @var Config\Configuration
+        * @var Config\IConfiguration
         */
        private $config;
 
@@ -89,7 +89,7 @@ Examples
 HELP;
        }
 
-       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\Configuration $config, Database $dba, array $argv = null)
+       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null)
        {
                parent::__construct($argv);
 
index 797f6394917586fe7d1d58f94f38a7446f02e0cc..38c60a1e2b53f14abbb268d1cb2d44c944955c9d 100644 (file)
@@ -4,7 +4,7 @@ namespace Friendica\Console;
 
 use Asika\SimpleConsole\CommandArgsException;
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use RuntimeException;
 
 /**
@@ -40,7 +40,7 @@ class Config extends \Asika\SimpleConsole\Console
         */
        private $appMode;
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -78,7 +78,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, Configuration $config, array $argv = null)
+       public function __construct(App\Mode $appMode, IConfiguration $config, array $argv = null)
        {
                parent::__construct($argv);
 
index 26b77a974148850343f5a740cf80793b13660b87..9633a50e9d124896f3cba31d971c6995bb811bb8 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Console;
 
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * @brief Sets maintenance mode for this node
@@ -19,7 +19,7 @@ class Maintenance extends \Asika\SimpleConsole\Console
         */
        private $appMode;
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -52,7 +52,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, Configuration $config, $argv = null)
+       public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null)
        {
                parent::__construct($argv);
 
index f6a7f69d223febe61d3387c885e15007e465c9d4..f3e81c1af5e77e9c0a4c89f14a3ff90055986d1b 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Console;
 
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\L10n\L10n;
 use Friendica\Core\Update;
 
@@ -24,7 +24,7 @@ class PostUpdate extends \Asika\SimpleConsole\Console
         */
        private $appMode;
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
        /**
@@ -46,7 +46,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(App\Mode $appMode, Configuration $config, L10n $l10n, array $argv = null)
+       public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null)
        {
                parent::__construct($argv);
 
index 322f8f6ee305feccb83315988646fa756739b904..f94c24dbd9eaf1f7fe4a42ec9a3ef843e8b0ddec 100644 (file)
@@ -5,7 +5,7 @@ namespace Friendica\Console;
 use Asika\SimpleConsole\CommandArgsException;
 use Asika\SimpleConsole\Console;
 use Console_Table;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * @brief Manage blocked servers
@@ -20,7 +20,7 @@ class ServerBlock extends Console
        protected $helpOptions = ['h', 'help', '?'];
 
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -49,7 +49,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(Configuration $config, $argv = null)
+       public function __construct(IConfiguration $config, $argv = null)
        {
                parent::__construct($argv);
 
@@ -77,9 +77,9 @@ HELP;
        /**
         * Prints the whole list of blocked domains including the reason
         *
-        * @param Configuration $config
+        * @param IConfiguration $config
         */
-       private function printBlockedServers(Configuration $config)
+       private function printBlockedServers(IConfiguration $config)
        {
                $table = new Console_Table();
                $table->setHeaders(['Domain', 'Reason']);
@@ -93,11 +93,11 @@ HELP;
        /**
         * Adds a server to the blocked list
         *
-        * @param Configuration $config
+        * @param IConfiguration $config
         *
         * @return int The return code (0 = success, 1 = failed)
         */
-       private function addBlockedServer(Configuration $config)
+       private function addBlockedServer(IConfiguration $config)
        {
                if (count($this->args) < 2 || count($this->args) > 3) {
                        throw new CommandArgsException('Add needs a domain and optional a reason.');
@@ -145,11 +145,11 @@ HELP;
        /**
         * Removes a server from the blocked list
         *
-        * @param Configuration $config
+        * @param IConfiguration $config
         *
         * @return int The return code (0 = success, 1 = failed)
         */
-       private function removeBlockedServer(Configuration $config)
+       private function removeBlockedServer(IConfiguration $config)
        {
                if (count($this->args) !== 2) {
                        throw new CommandArgsException('Remove needs a second parameter.');
index 855c1705c2e19fc33924110436aade1b699bdf63..a0b6e3691ce477971cd5b97035fd95f88a2fa4ea 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Friendica\Console;
 
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * Tired of chasing typos and finding them after a commit.
@@ -15,7 +15,7 @@ class Typo extends \Asika\SimpleConsole\Console
        protected $helpOptions = ['h', 'help', '?'];
 
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -36,7 +36,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(Configuration $config, array $argv = null)
+       public function __construct(IConfiguration $config, array $argv = null)
        {
                parent::__construct($argv);
 
index 6797a70c2b9a919ae40b73b86f5d390a312a8fce..5bf231b398d75281e51208ed55e4766f57e6f6c4 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Core\Cache;
 
 use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Memcache;
 
 /**
@@ -25,7 +25,7 @@ class MemcacheCache extends Cache implements IMemoryCache
        /**
         * @throws Exception
         */
-       public function __construct(string $hostname, Configuration $config)
+       public function __construct(string $hostname, IConfiguration $config)
        {
                if (!class_exists('Memcache', false)) {
                        throw new Exception('Memcache class isn\'t available');
index 95bfae39f25d0100f31118aaf5166c412e8c81c5..5476e3766acf1e7d119ddc8217876d8c55418dd8 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Core\Cache;
 
 use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Memcached;
 use Psr\Log\LoggerInterface;
 
@@ -39,7 +39,7 @@ class MemcachedCache extends Cache implements IMemoryCache
         *
         * @throws \Exception
         */
-       public function __construct(string $hostname, Configuration $config, LoggerInterface $logger)
+       public function __construct(string $hostname, IConfiguration $config, LoggerInterface $logger)
        {
                if (!class_exists('Memcached', false)) {
                        throw new Exception('Memcached class isn\'t available');
index 3558a38464ca9c20acdf343b04e31b1a207c9c04..7af9f3d236f13d09dfba57cc4acbad779a1a9eca 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Core\Cache;
 
 use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Redis;
 
 /**
@@ -22,7 +22,7 @@ class RedisCache extends Cache implements IMemoryCache
        /**
         * @throws Exception
         */
-       public function __construct(string $hostname, Configuration $config)
+       public function __construct(string $hostname, IConfiguration $config)
        {
                if (!class_exists('Redis', false)) {
                        throw new Exception('Redis class isn\'t available');
index c54fbb27e76a12466621bc7bd2155be1ba80c276..9094441bf6ceadec805790f04ac5f3d8e309bd2d 100644 (file)
@@ -10,7 +10,7 @@ use Friendica\Model;
  * - The Config-Files    (loaded into the FileCache @see Cache\ConfigCache)
  * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
  */
-abstract class Configuration
+abstract class Configuration implements IConfiguration
 {
        /**
         * @var Cache\ConfigCache
@@ -33,68 +33,10 @@ abstract class Configuration
        }
 
        /**
-        * Returns the Config Cache
-        *
-        * @return Cache\ConfigCache
+        * {@inheritDoc}
         */
        public function getCache()
        {
                return $this->configCache;
        }
-
-       /**
-        * @brief Loads all configuration values of family into a cached storage.
-        *
-        * All configuration values of the system are stored in the cache ( @see ConfigCache )
-        *
-        * @param string $cat The category of the configuration value
-        *
-        * @return void
-        */
-       abstract public function load(string $cat = 'config');
-
-       /**
-        * @brief Get a particular user's config variable given the category name
-        * ($cat) and a $key.
-        *
-        * Get a particular config value from the given category ($cat)
-        * and the $key from a cached storage either from the $this->configAdapter
-        * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
-        *
-        * @param string  $cat        The category of the configuration value
-        * @param string  $key           The configuration key to query
-        * @param mixed   $default_value optional, The value to return if key is not set (default: null)
-        * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
-        *
-        * @return mixed Stored value or null if it does not exist
-        */
-       abstract public function get(string $cat, string $key, $default_value = null, bool $refresh = false);
-
-       /**
-        * @brief Sets a configuration value for system config
-        *
-        * Stores a config value ($value) in the category ($cat) under the key ($key)
-        *
-        * Note: Please do not store booleans - convert to 0/1 integer values!
-        *
-        * @param string $cat The category of the configuration value
-        * @param string $key    The configuration key to set
-        * @param mixed  $value  The value to store
-        *
-        * @return bool Operation success
-        */
-       abstract public function set(string $cat, string $key, $value);
-
-       /**
-        * @brief Deletes the given key from the system configuration.
-        *
-        * Removes the configured value from the stored cache in $this->configCache
-        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
-        *
-        * @param string $cat The category of the configuration value
-        * @param string $key    The configuration key to delete
-        *
-        * @return bool
-        */
-       abstract public function delete(string $cat, string $key);
 }
diff --git a/src/Core/Config/IConfiguration.php b/src/Core/Config/IConfiguration.php
new file mode 100644 (file)
index 0000000..4bd44f0
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+namespace Friendica\Core\Config;
+
+/**
+ * Interface for accessing system wide configurations
+ */
+interface IConfiguration
+{
+
+       /**
+        * @brief Loads all configuration values of family into a cached storage.
+        *
+        * All configuration values of the system are stored in the cache ( @see ConfigCache )
+        *
+        * @param string $cat The category of the configuration value
+        *
+        * @return void
+        */
+       function load(string $cat = 'config');
+
+       /**
+        * @brief Get a particular user's config variable given the category name
+        * ($cat) and a $key.
+        *
+        * Get a particular config value from the given category ($cat)
+        * and the $key from a cached storage either from the $this->configAdapter
+        * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
+        *
+        * @param string  $cat        The category of the configuration value
+        * @param string  $key           The configuration key to query
+        * @param mixed   $default_value optional, The value to return if key is not set (default: null)
+        * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
+        *
+        * @return mixed Stored value or null if it does not exist
+        */
+       function get(string $cat, string $key, $default_value = null, bool $refresh = false);
+
+       /**
+        * @brief Sets a configuration value for system config
+        *
+        * Stores a config value ($value) in the category ($cat) under the key ($key)
+        *
+        * Note: Please do not store booleans - convert to 0/1 integer values!
+        *
+        * @param string $cat The category of the configuration value
+        * @param string $key    The configuration key to set
+        * @param mixed  $value  The value to store
+        *
+        * @return bool Operation success
+        */
+       function set(string $cat, string $key, $value);
+
+       /**
+        * @brief Deletes the given key from the system configuration.
+        *
+        * Removes the configured value from the stored cache in $this->configCache
+        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
+        *
+        * @param string $cat The category of the configuration value
+        * @param string $key    The configuration key to delete
+        *
+        * @return bool
+        */
+       function delete(string $cat, string $key);
+
+       /**
+        * Returns the Config Cache
+        *
+        * @return Cache\ConfigCache
+        */
+       function getCache();
+}
diff --git a/src/Core/Config/IPConfiguration.php b/src/Core/Config/IPConfiguration.php
new file mode 100644 (file)
index 0000000..23d75eb
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+
+namespace Friendica\Core\Config;
+
+/**
+ * Interface for accessing user specific configurations
+ */
+interface IPConfiguration
+{
+
+       /**
+        * Loads all configuration values of a user's config family into a cached storage.
+        *
+        * All configuration values of the given user are stored with the $uid in the cache
+        *
+        * @param int $uid The user_id
+        * @param string $cat The category of the configuration value
+        *
+        * @return void
+        * @see PConfigCache
+        *
+        */
+       function load(int $uid, string $cat = 'config');
+
+       /**
+        * Get a particular user's config variable given the category name
+        * ($cat) and a key.
+        *
+        * Get a particular user's config value from the given category ($cat)
+        * and the $key with the $uid from a cached storage either from the $this->configAdapter
+        * (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
+        *
+        * @param int     $uid           The user_id
+        * @param string  $cat           The category of the configuration value
+        * @param string  $key           The configuration key to query
+        * @param mixed   $default_value optional, The value to return if key is not set (default: null)
+        * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
+        *
+        * @return mixed Stored value or null if it does not exist
+        */
+       function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
+
+       /**
+        * Sets a configuration value for a user
+        *
+        * Stores a config value ($value) in the category ($family) under the key ($key)
+        * for the user_id $uid.
+        *
+        * @note  Please do not store booleans - convert to 0/1 integer values!
+        *
+        * @param int    $uid   The user_id
+        * @param string $cat   The category of the configuration value
+        * @param string $key   The configuration key to set
+        * @param mixed  $value The value to store
+        *
+        * @return bool Operation success
+        */
+       function set(int $uid, string $cat, string $key, $value);
+
+       /**
+        * Deletes the given key from the users's configuration.
+        *
+        * Removes the configured value from the stored cache in $this->configCache
+        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
+        *  with the given $uid.
+        *
+        * @param int $uid The user_id
+        * @param string $cat The category of the configuration value
+        * @param string $key The configuration key to delete
+        *
+        * @return bool
+        */
+       function delete(int $uid, string $cat, string $key);
+
+
+       /**
+        * Returns the Config Cache
+        *
+        * @return Cache\PConfigCache
+        */
+       function getCache();
+}
index c54fc31220361c7d3e1e3696a5f972a1f2635f0e..ee90be322556c68abd37d0b9e736896e1fb74a1c 100644 (file)
@@ -11,7 +11,7 @@ use Friendica\Model;
  * The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
  * increase the performance.
  */
-abstract class PConfiguration
+abstract class PConfiguration implements IPConfiguration
 {
        /**
         * @var Cache\PConfigCache
@@ -42,68 +42,4 @@ abstract class PConfiguration
        {
                return $this->configCache;
        }
-
-       /**
-        * Loads all configuration values of a user's config family into a cached storage.
-        *
-        * All configuration values of the given user are stored with the $uid in the cache
-        *
-        * @param int $uid The user_id
-        * @param string $cat The category of the configuration value
-        *
-        * @return void
-        * @see PConfigCache
-        *
-        */
-       abstract public function load(int $uid, string $cat = 'config');
-
-       /**
-        * Get a particular user's config variable given the category name
-        * ($cat) and a key.
-        *
-        * Get a particular user's config value from the given category ($cat)
-        * and the $key with the $uid from a cached storage either from the $this->configAdapter
-        * (@see IConfigAdapter) or from the $this->configCache (@see PConfigCache).
-        *
-        * @param int     $uid           The user_id
-        * @param string  $cat           The category of the configuration value
-        * @param string  $key           The configuration key to query
-        * @param mixed   $default_value optional, The value to return if key is not set (default: null)
-        * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
-        *
-        * @return mixed Stored value or null if it does not exist
-        */
-       abstract public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
-
-       /**
-        * Sets a configuration value for a user
-        *
-        * Stores a config value ($value) in the category ($family) under the key ($key)
-        * for the user_id $uid.
-        *
-        * @note  Please do not store booleans - convert to 0/1 integer values!
-        *
-        * @param int    $uid   The user_id
-        * @param string $cat   The category of the configuration value
-        * @param string $key   The configuration key to set
-        * @param mixed  $value The value to store
-        *
-        * @return bool Operation success
-        */
-       abstract public function set(int $uid, string $cat, string $key, $value);
-
-       /**
-        * Deletes the given key from the users's configuration.
-        *
-        * Removes the configured value from the stored cache in $this->configCache
-        * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
-        *  with the given $uid.
-        *
-        * @param int $uid The user_id
-        * @param string $cat The category of the configuration value
-        * @param string $key The configuration key to delete
-        *
-        * @return bool
-        */
-       abstract public function delete(int $uid, string $cat, string $key);
 }
index ad4f6537160464bf0b5a94ef92478e48fac5c0f8..8b2238c7ae6ae165ee9d95a866e01ddf16b231c3 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Friendica\Core\L10n;
 
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Hook;
 use Friendica\Core\Session\ISession;
 use Friendica\Database\Database;
@@ -41,7 +41,7 @@ class L10n
         */
        private $logger;
 
-       public function __construct(Configuration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
+       public function __construct(IConfiguration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
        {
                $this->dba    = $dba;
                $this->logger = $logger;
index 035f4bf0af46fab7e533df0bc71e4945cc1f0411..a7f8de2866dab66328b1d7a59fb5cd9dfb58a6eb 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Core;
 
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -28,7 +28,7 @@ final class Process
        private $mode;
 
        /**
-        * @var Configuration
+        * @var IConfiguration
         */
        private $config;
 
@@ -37,7 +37,7 @@ final class Process
         */
        private $basePath;
 
-       public function __construct(LoggerInterface $logger, App\Mode $mode, Configuration $config, string $basepath)
+       public function __construct(LoggerInterface $logger, App\Mode $mode, IConfiguration $config, string $basepath)
        {
                $this->logger   = $logger;
                $this->mode     = $mode;
index c3f6d07f9ce4faf8b18c82fc4cc5752c8a0cfe4a..09969f29a99bec2ae2d8f1fddd3ebfa1c4e59724 100644 (file)
@@ -4,8 +4,8 @@ namespace Friendica;
 
 use Dice\Dice;
 use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
 use Friendica\Core\L10n\L10n;
 use Friendica\Core\Lock\ILock;
 use Friendica\Core\Process;
@@ -34,8 +34,8 @@ use Psr\Log\LoggerInterface;
  * @method static Content\Text\BBCode\Video bbCodeVideo()
  * @method static DateTimeFormat dtFormat()
  * @method static ICache cache()
- * @method static Configuration config()
- * @method static PConfiguration pConfig()
+ * @method static IConfiguration config()
+ * @method static IPConfiguration pConfig()
  * @method static ILock lock()
  * @method static L10n l10n()
  * @method static LoggerInterface logger()
@@ -73,8 +73,8 @@ class DI
                'bbCodeVideo'  => Content\Text\BBCode\Video::class,
                'dtFormat'     => DateTimeFormat::class,
                'cache'        => ICache::class,
-               'config'       => Configuration::class,
-               'pConfig'      => PConfiguration::class,
+               'config'       => IConfiguration::class,
+               'pConfig'      => IPConfiguration::class,
                'l10n'         => L10n::class,
                'lock'         => ILock::class,
                'logger'       => LoggerInterface::class,
index 39b0b94ff7b5d8e6ddcd7fd07a38bd33cd0e8de3..4e4fc67915d10b94373231e5cbdeaa9ec609c13b 100644 (file)
@@ -5,7 +5,7 @@ namespace Friendica\Factory;
 use Friendica\App\BaseURL;
 use Friendica\Core\Cache;
 use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Database\Database;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
@@ -25,7 +25,7 @@ class CacheFactory
        const DEFAULT_TYPE = Cache\Cache::TYPE_DATABASE;
 
        /**
-        * @var Configuration The configuration to read parameters out of the config
+        * @var IConfiguration The IConfiguration to read parameters out of the config
         */
        private $config;
 
@@ -49,7 +49,7 @@ class CacheFactory
         */
        private $logger;
 
-       public function __construct(BaseURL $baseURL, Configuration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
+       public function __construct(BaseURL $baseURL, IConfiguration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
        {
                $this->hostname = $baseURL->getHostname();
                $this->config   = $config;
index 494a5c7209ae2d55323e57832a1fc56dcb935909..ecec1e2a730e314cc498baa9705508885757d086 100644 (file)
@@ -27,7 +27,7 @@ class ConfigFactory
         * @param Cache\ConfigCache $configCache The config cache of this adapter
         * @param ConfigModel       $configModel The configuration model
         *
-        * @return Config\Configuration
+        * @return Config\IConfiguration
         */
        public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
        {
@@ -46,7 +46,7 @@ class ConfigFactory
         * @param Cache\PConfigCache $pConfigCache The personal config cache
         * @param PConfigModel       $configModel  The configuration model
         *
-        * @return Config\PConfiguration
+        * @return Config\IPConfiguration
         */
        public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
        {
index cee01fe1e9d2647aef5fb9b8b440b0621ae4e3b6..a7e9bf429b0c0afc3dc33f3500aff4987869390d 100644 (file)
@@ -4,7 +4,7 @@ namespace Friendica\Factory;
 
 use Friendica\Core\Cache\Cache;
 use Friendica\Core\Cache\IMemoryCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Lock;
 use Friendica\Database\Database;
 use Psr\Log\LoggerInterface;
@@ -24,7 +24,7 @@ class LockFactory
        const DEFAULT_DRIVER = 'default';
 
        /**
-        * @var Configuration The configuration to read parameters out of the config
+        * @var IConfiguration The configuration to read parameters out of the config
         */
        private $config;
 
@@ -43,7 +43,7 @@ class LockFactory
         */
        private $logger;
 
-       public function __construct(CacheFactory $cacheFactory, Configuration $config, Database $dba, LoggerInterface $logger)
+       public function __construct(CacheFactory $cacheFactory, IConfiguration $config, Database $dba, LoggerInterface $logger)
        {
                $this->cacheFactory = $cacheFactory;
                $this->config       = $config;
index f21fe9b7f50fa04f6de3f7b24fecc42a34bc5b20..0dae19a25055a199804107885d3d88d5c9d215e0 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Friendica\Factory;
 
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Logger;
 use Friendica\Database\Database;
 use Friendica\Network\HTTPException\InternalServerErrorException;
@@ -50,13 +50,13 @@ class LoggerFactory
         * Creates a new PSR-3 compliant logger instances
         *
         * @param Database      $database The Friendica Database instance
-        * @param Configuration $config   The config
+        * @param IConfiguration $config   The config
         * @param Profiler      $profiler The profiler of the app
         * @param FileSystem    $fileSystem FileSystem utils
         *
         * @return LoggerInterface The PSR-3 compliant logger instance
         */
-       public function create(Database $database, Configuration $config, Profiler $profiler, FileSystem $fileSystem)
+       public function create(Database $database, IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
        {
                if (empty($config->get('system', 'debugging', false))) {
                        $logger = new VoidLogger();
@@ -137,7 +137,7 @@ class LoggerFactory
         *
         * It should never get filled during normal usage of Friendica
         *
-        * @param Configuration $config   The config
+        * @param IConfiguration $config   The config
         * @param Profiler      $profiler The profiler of the app
         * @param FileSystem    $fileSystem FileSystem utils
         *
@@ -146,7 +146,7 @@ class LoggerFactory
         * @throws InternalServerErrorException
         * @throws \Exception
         */
-       public static function createDev(Configuration $config, Profiler $profiler, FileSystem $fileSystem)
+       public static function createDev(IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
        {
                $debugging   = $config->get('system', 'debugging');
                $stream      = $config->get('system', 'dlogfile');
index eb2371d452ce302e1e32f27abb7fe673dffdd225..c03f429dc949b38024ff53908c27fb65d7fb5427 100644 (file)
@@ -5,7 +5,7 @@ namespace Friendica\Factory;
 use Friendica\App;
 use Friendica\Core\Cache\Cache;
 use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\Database;
@@ -29,7 +29,8 @@ class SessionFactory
        /**
         * @param App\Mode        $mode
         * @param App\BaseURL     $baseURL
-        * @param Configuration   $config
+        * @param IConfiguration  $config
+        * @param Cookie          $cookie
         * @param Database        $dba
         * @param ICache          $cache
         * @param LoggerInterface $logger
@@ -37,7 +38,7 @@ class SessionFactory
         *
         * @return Session\ISession
         */
-       public function createSession(App\Mode $mode, App\BaseURL $baseURL, Configuration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
+       public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfiguration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
        {
                $stamp1  = microtime(true);
                $session = null;
index 160d261b16a1d8cf2fa3a68b00f1f3f056932741..10ece48e2d5bb2d179b9b8ecd942ca6379ebee56 100644 (file)
@@ -6,7 +6,7 @@ use Exception;
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IPConfiguration;
 use Friendica\Core\L10n\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
@@ -71,13 +71,13 @@ final class Notify
        private $args;
        /** @var App\BaseURL */
        private $baseUrl;
-       /** @var PConfiguration */
+       /** @var IPConfiguration */
        private $pConfig;
        /** @var LoggerInterface */
        private $logger;
 
        public function __construct(Database $dba, L10n $l10n, App\Arguments $args, App\BaseURL $baseUrl,
-                                   PConfiguration $pConfig, LoggerInterface $logger)
+                                   IPConfiguration $pConfig, LoggerInterface $logger)
        {
                $this->dba     = $dba;
                $this->l10n    = $l10n;
index 0fc90222f1a406f56567f5601b920672f353a2fe..e065d33e2e3e54cb75eeb61c621f3b5fa2a60bcd 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Model\User;
 
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * Interacting with the Friendica Cookie of a user
@@ -32,7 +32,7 @@ class Cookie
        /** @var array The $_COOKIE array */
        private $cookie;
 
-       public function __construct(Configuration $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
+       public function __construct(IConfiguration $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
        {
                if (!empty($server['REMOTE_ADDR'])) {
                        $this->remoteAddr = $server['REMOTE_ADDR'];
index 4b6bb2a52e935d37a5e53e4552e5e13a82645f62..dbfb7f549fb0b180237a98f0c74bd53e2c07b188 100644 (file)
@@ -2,10 +2,7 @@
 
 namespace Friendica\Module\Diaspora;
 
-use Friendica\App;
 use Friendica\BaseModule;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\L10n\L10n;
 use Friendica\DI;
 use Friendica\Model\User;
 use Friendica\Network\HTTPException;
index e745a8bbdf001e528cb5735a411698b8b43e0436..d166210e33182000d8318a0a932abe00cd2aea5b 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Util;
 
 use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Psr\Container\ContainerExceptionInterface;
 use Psr\Container\ContainerInterface;
 use Psr\Container\NotFoundExceptionInterface;
@@ -47,9 +47,9 @@ class Profiler implements ContainerInterface
        /**
         * Updates the enabling of the current profiler
         *
-        * @param Configuration $config
+        * @param IConfiguration $config
         */
-       public function update(Configuration $config)
+       public function update(IConfiguration $config)
        {
                $this->enabled = $config->get('system', 'profiler');
                $this->rendertime = $config->get('rendertime', 'callstack');
index ea9830679f426d74a609bc34407e74da2d83d006..512d0e7a2c10d30472f6b1516d6780615faa2b67 100644 (file)
@@ -68,13 +68,13 @@ return [
                        ['determine', [], Dice::CHAIN_CALL],
                ],
        ],
-       Config\Configuration::class     => [
+       Config\IConfiguration::class     => [
                'instanceOf' => Factory\ConfigFactory::class,
                'call'       => [
                        ['createConfig', [], Dice::CHAIN_CALL],
                ],
        ],
-       Config\PConfiguration::class    => [
+       Config\IPConfiguration::class    => [
                'instanceOf' => Factory\ConfigFactory::class,
                'call'       => [
                        ['createPConfig', [], Dice::CHAIN_CALL],
index f9a9cb25de41902d90187fe2966046f5322bd9a9..7948f09f602efdac1ee11ca268dd243f19599881 100644 (file)
@@ -22,7 +22,7 @@ trait AppMockTrait
        protected $app;
 
        /**
-        * @var MockInterface|Config\Configuration The mocked Config Cache
+        * @var MockInterface|Config\IConfiguration The mocked Config Cache
         */
        protected $configMock;
 
@@ -54,11 +54,11 @@ trait AppMockTrait
 
                $this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
                $this->dice->shouldReceive('create')
-                          ->with(Config\Cache\ConfigCache::class)
+                          ->with(Config\Cache\ConfigCache::class, [])
                           ->andReturn($this->configMock);
                $this->mode = \Mockery::mock(App\Mode::class);
                $this->dice->shouldReceive('create')
-                          ->with(App\Mode::class)
+                          ->with(App\Mode::class, [])
                           ->andReturn($this->mode);
                $configModel= \Mockery::mock(\Friendica\Model\Config\Config::class);
                // Disable the adapter
@@ -66,13 +66,13 @@ trait AppMockTrait
 
                $config = new Config\JitConfiguration($this->configMock, $configModel);
                $this->dice->shouldReceive('create')
-                          ->with(Config\Configuration::class)
+                          ->with(Config\IConfiguration::class, [])
                           ->andReturn($config);
 
                // Mocking App and most used functions
                $this->app = \Mockery::mock(App::class);
                $this->dice->shouldReceive('create')
-                          ->with(App::class)
+                          ->with(App::class, [])
                           ->andReturn($this->app);
                $this->app
                        ->shouldReceive('getBasePath')
@@ -85,7 +85,7 @@ trait AppMockTrait
                $this->profilerMock = \Mockery::mock(Profiler::class);
                $this->profilerMock->shouldReceive('saveTimestamp');
                $this->dice->shouldReceive('create')
-                          ->with(Profiler::class)
+                          ->with(Profiler::class, [])
                           ->andReturn($this->profilerMock);
 
                $this->app
index a839dbed73c832fcfa8ab773bc154a6fd1b251a0..8b4b8ade1ebb473c0ff3ffe62f12fc55ee0de3c0 100644 (file)
@@ -3,9 +3,16 @@
  * This file is loaded by PHPUnit before any test.
  */
 
+use Dice\Dice;
+use Friendica\DI;
 use PHPUnit\Framework\TestCase;
 
 // Backward compatibility
 if (!class_exists(TestCase::class)) {
        class_alias(PHPUnit_Framework_TestCase::class, TestCase::class);
 }
+
+$dice = new Dice();
+$dice = $dice->addRules(include  __DIR__ . '/../static/dependencies.config.php');
+
+DI::init($dice);
index 336a34c344add825005b6a3fcf06f6dd61a42122..4e05845f29cb3de682171e3916e4cb78b638af2d 100644 (file)
@@ -7,7 +7,7 @@ use Friendica\App;
 use Friendica\Core\Cache\ICache;
 use Friendica\Core\Cache\IMemoryCache;
 use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Lock\ILock;
 use Friendica\Database\Database;
 use Friendica\Test\Util\VFSTrait;
@@ -115,10 +115,10 @@ class dependencyCheck extends TestCase
 
        public function testConfiguration()
        {
-               /** @var Configuration $config */
-               $config = $this->dice->create(Configuration::class);
+               /** @var IConfiguration $config */
+               $config = $this->dice->create(IConfiguration::class);
 
-               $this->assertInstanceOf(Configuration::class, $config);
+               $this->assertInstanceOf(IConfiguration::class, $config);
 
                $this->assertNotEmpty($config->get('database', 'username'));
        }
@@ -133,8 +133,8 @@ class dependencyCheck extends TestCase
 
        public function testDevLogger()
        {
-               /** @var Configuration $config */
-               $config = $this->dice->create(Configuration::class);
+               /** @var IConfiguration $config */
+               $config = $this->dice->create(IConfiguration::class);
                $config->set('system', 'dlogfile', $this->root->url() . '/friendica.log');
 
                /** @var LoggerInterface $logger */
index 74c220d8492f94756f3c49423fd703184a610ecc..8fce36955de8315b3edfaffda55a594f9a684afd 100644 (file)
@@ -7,8 +7,8 @@ namespace Friendica\Test;
 
 use Dice\Dice;
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
 use Friendica\Core\Protocol;
 use Friendica\Core\Session;
 use Friendica\Core\Session\ISession;
@@ -47,7 +47,7 @@ class ApiTest extends DatabaseTest
        /** @var App */
        protected $app;
 
-       /** @var Configuration */
+       /** @var IConfiguration */
        protected $config;
 
        /** @var Dice */
@@ -69,8 +69,8 @@ class ApiTest extends DatabaseTest
                /** @var Database $dba */
                $dba = $this->dice->create(Database::class);
 
-               /** @var Configuration $config */
-               $this->config = $this->dice->create(Configuration::class);
+               /** @var IConfiguration $config */
+               $this->config = $this->dice->create(IConfiguration::class);
 
                $this->config->set('system', 'url', 'http://localhost');
                $this->config->set('system', 'hostname', 'localhost');
@@ -827,7 +827,7 @@ class ApiTest extends DatabaseTest
         */
        public function testApiGetUserWithFrioSchema()
        {
-               $pConfig = $this->dice->create(PConfiguration::class);
+               $pConfig = $this->dice->create(IPConfiguration::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(PConfiguration::class);
+               $pConfig = $this->dice->create(IPConfiguration::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(PConfiguration::class);
+               $pConfig = $this->dice->create(IPConfiguration::class);
                $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
                $user = api_get_user($this->app);
                $this->assertSelfUser($user);
diff --git a/tests/phpunit-local.xml b/tests/phpunit-local.xml
new file mode 100644 (file)
index 0000000..7bf174a
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<phpunit
+       bootstrap="bootstrap.php"
+       verbose="true">
+       <testsuite name='friendica'>
+               <directory suffix='.php'>functional/</directory>
+               <directory suffix='.php'>include/</directory>
+               <directory suffix='.php'>src/</directory>
+               <directory suffix='.php'>./</directory>
+       </testsuite>
+       <!-- Filters for Code Coverage -->
+       <filter>
+               <whitelist>
+                       <directory suffix=".php">..</directory>
+                       <exclude>
+                               <directory suffix=".php">config/</directory>
+                               <directory suffix=".php">doc/</directory>
+                               <directory suffix=".php">images/</directory>
+                               <directory suffix=".php">library/</directory>
+                               <directory suffix=".php">spec/</directory>
+                               <directory suffix=".php">tests/</directory>
+                               <directory suffix=".php">view/</directory>
+                       </exclude>
+               </whitelist>
+       </filter>
+</phpunit>
index ce2a40b80640bca61ee2a4caa4fdf9b30527763b..f1ac6bb92e275b7ea492bff2f00457ec86b7b1bc 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Test\src\App;
 
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\LegacyModule;
 use Friendica\Module\HTTPException\PageNotFound;
 use Friendica\Module\WellKnown\HostMeta;
@@ -149,7 +149,7 @@ class ModuleTest extends DatabaseTest
         */
        public function testModuleClass($assert, string $name, string $command, bool $privAdd)
        {
-               $config = \Mockery::mock(Configuration::class);
+               $config = \Mockery::mock(IConfiguration::class);
                $config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once();
 
                $router = (new App\Router([]))->loadRoutes(include __DIR__ . '/../../../static/routes.config.php');
index e4206af4144302b20bd5dca0d55e0bc2b256343e..51342bf1694a028a7b920c34796a62b916409113 100644 (file)
@@ -5,7 +5,7 @@ namespace Friendica\Test\src\Console;
 use Friendica\App;
 use Friendica\App\Mode;
 use Friendica\Console\Config;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Mockery\MockInterface;
 
 class ConfigConsoleTest extends ConsoleTest
@@ -29,7 +29,7 @@ class ConfigConsoleTest extends ConsoleTest
                $this->appMode->shouldReceive('has')
                        ->andReturn(true);
 
-               $this->configMock = \Mockery::mock(Configuration::class);
+               $this->configMock = \Mockery::mock(IConfiguration::class);
        }
 
        function testSetGetKeyValue()
index d671020e6f59c458bb416d72f97ba1ddb8160604..ef6cc0dacb8f44c3eec9c0b34e331588b270bbb6 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Test\src\Console;
 
 use Friendica\Console\ServerBlock;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 class ServerBlockConsoleTest extends ConsoleTest
 {
@@ -22,7 +22,7 @@ class ServerBlockConsoleTest extends ConsoleTest
        {
                parent::setUp();
 
-               $this->configMock = \Mockery::mock(Configuration::class);
+               $this->configMock = \Mockery::mock(IConfiguration::class);
        }
 
        /**
index ed33306edf85bb395504bf53293374d669a387f3..52d01401e64a8cb11c86c792c281216e9f69e913 100644 (file)
@@ -43,13 +43,13 @@ class BBCodeTest extends MockedTest
                $l10nMock = \Mockery::mock(L10n::class);
                $l10nMock->shouldReceive('t')->withAnyArgs()->andReturnUsing(function ($args) { return $args; });
                $this->dice->shouldReceive('create')
-                          ->with(L10n::class)
+                          ->with(L10n::class, [])
                           ->andReturn($l10nMock);
 
                $baseUrlMock = \Mockery::mock(BaseURL::class);
                $baseUrlMock->shouldReceive('get')->withAnyArgs()->andReturn('friendica.local');
                $this->dice->shouldReceive('create')
-                          ->with(BaseURL::class)
+                          ->with(BaseURL::class, [])
                           ->andReturn($baseUrlMock);
        }
 
index 2865effb17ad9c9cfb9acf6f9b814414be1c5a54..be7946717e4972d3e5a29617e240b4d19bfb1a19 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Test\src\Core\Cache;
 
 use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * @requires extension memcache
@@ -13,7 +13,7 @@ class MemcacheCacheTest extends MemoryCacheTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
 
index c9eb02be6e74c94ae68b2b8303989fa5f6304a63..addbde627505dc63c17042c70121cd846d496d07 100644 (file)
@@ -4,7 +4,7 @@
 namespace Friendica\Test\src\Core\Cache;
 
 use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Psr\Log\NullLogger;
 
 /**
@@ -15,7 +15,7 @@ class MemcachedCacheTest extends MemoryCacheTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
 
index 75891cd1b8f1d7514694d48b5fd0147d92292cde..53c2ecc8333d26e91d1741607c57d4c34c79af62 100644 (file)
@@ -4,7 +4,7 @@
 namespace Friendica\Test\src\Core\Cache;
 
 use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 
 /**
  * @requires extension redis
@@ -14,7 +14,7 @@ class RedisCacheTest extends MemoryCacheTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
 
index 2191d86f1cbe9b0ca663286f5ac87a78d2df7288..15c96ca936e90fee931bcc4f9c1e55943daeed9a 100644 (file)
@@ -3,8 +3,7 @@
 namespace Friendica\Test\src\Core\Config;
 
 use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\JitConfiguration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Model\Config\Config as ConfigModel;
 use Friendica\Test\MockedTest;
 use Mockery\MockInterface;
@@ -18,7 +17,7 @@ abstract class ConfigurationTest extends MockedTest
        /** @var ConfigCache */
        protected $configCache;
 
-       /** @var Configuration */
+       /** @var IConfiguration */
        protected $testedConfig;
 
        /**
@@ -47,7 +46,7 @@ abstract class ConfigurationTest extends MockedTest
        }
 
        /**
-        * @return Configuration
+        * @return IConfiguration
         */
        public abstract function getInstance();
 
index b2ef92b450c6f2d96428fb0bd195f5609a22fd20..674195c128878a550c7af1c28c4bacf2976aab45 100644 (file)
@@ -34,7 +34,7 @@ class InstallerTest extends MockedTest
                $dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
 
                $dice->shouldReceive('create')
-                          ->with(\Friendica\Core\L10n\L10n::class)
+                          ->with(\Friendica\Core\L10n\L10n::class, [])
                           ->andReturn($this->l10nMock);
 
                DI::init($dice);
@@ -362,7 +362,7 @@ class InstallerTest extends MockedTest
                $this->assertTrue($install->checkImagick());
 
                $this->assertCheckExist(1,
-                       L10n::t('ImageMagick supports GIF'),
+                       $this->l10nMock->t('ImageMagick supports GIF'),
                        '',
                        true,
                        false,
@@ -385,9 +385,9 @@ class InstallerTest extends MockedTest
                // even there is no supported type, Imagick should return true (because it is not required)
                $this->assertTrue($install->checkImagick());
                $this->assertCheckExist(1,
-                       L10n::t('ImageMagick supports GIF'),
+                       $this->l10nMock->t('ImageMagick supports GIF'),
                        '',
-                       false,
+                       true,
                        false,
                        $install->getChecks());
        }
index e66c4725c17be7f87a9d691915db0a8beceb4133..9e111fbb925e074740c35f566c18ca995b2f5b00 100644 (file)
@@ -4,7 +4,7 @@
 namespace Friendica\Test\src\Core\Lock;
 
 use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Lock\CacheLock;
 
 /**
@@ -15,7 +15,7 @@ class MemcacheCacheLockTest extends LockTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
 
index c217b47f59a8673aa7f755e7edecb8fea384603f..41b16abc7fbcaa76e371771f6e683b9cef64802c 100644 (file)
@@ -4,7 +4,7 @@
 namespace Friendica\Test\src\Core\Lock;
 
 use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Lock\CacheLock;
 use Psr\Log\NullLogger;
 
@@ -16,7 +16,7 @@ class MemcachedCacheLockTest extends LockTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
 
index 95f7206e2c79d73367c2f12bd9b8da98c2b54462..bfda18b24d9822e59d065218cf1586b627a53d0c 100644 (file)
@@ -4,7 +4,7 @@
 namespace Friendica\Test\src\Core\Lock;
 
 use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Lock\CacheLock;
 
 /**
@@ -15,7 +15,7 @@ class RedisCacheLockTest extends LockTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
 
                $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
 
index 040cdeb5214c03598d52ce99b2d173e26902ad1f..51d3866fe719d0b2e979f6ec7556709b7d9326d7 100644 (file)
@@ -4,27 +4,29 @@ namespace Friendica\Test\src\Core\Lock;
 
 use Dice\Dice;
 use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Core\Config\JitConfiguration;
 use Friendica\Core\Lock\SemaphoreLock;
 use Friendica\DI;
+use Mockery\MockInterface;
 
 class SemaphoreLockTest extends LockTest
 {
        public function setUp()
        {
+               /** @var MockInterface|Dice $dice */
                $dice = \Mockery::mock(Dice::class)->makePartial();
 
                $app = \Mockery::mock(App::class);
                $app->shouldReceive('getHostname')->andReturn('friendica.local');
-               $dice->shouldReceive('create')->with(App::class)->andReturn($app);
+               $dice->shouldReceive('create')->with(App::class, [])->andReturn($app);
 
                $configMock = \Mockery::mock(JitConfiguration::class);
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'temppath', NULL, false)
                        ->andReturn('/tmp/');
-               $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
+               $dice->shouldReceive('create')->with(IConfiguration::class, [])->andReturn($configMock);
 
                // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
                DI::init($dice);
index b689fc97c85cc547617a039a437bf50c53b926ba..f66e5a6ae6560fc2a1ce075d66c7ac69f1010e9d 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Testsrc\Model\User;
 
 use Friendica\App\BaseURL;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Model\User\Cookie;
 use Friendica\Test\DatabaseTest;
 use Friendica\Test\Util\StaticCookie;
@@ -11,7 +11,7 @@ use Mockery\MockInterface;
 
 class CookieTest extends DatabaseTest
 {
-       /** @var MockInterface|Configuration */
+       /** @var MockInterface|IConfiguration */
        private $config;
        /** @var MockInterface|BaseURL */
        private $baseUrl;
@@ -22,7 +22,7 @@ class CookieTest extends DatabaseTest
 
                parent::setUp();
 
-               $this->config = \Mockery::mock(Configuration::class);
+               $this->config = \Mockery::mock(IConfiguration::class);
                $this->baseUrl = \Mockery::mock(BaseURL::class);
        }
 
index 7f2754a0e5c223b48583417b0eb3ab50323aa68b..294be6b0b2067f19d4f698771792ad8571b790e8 100644 (file)
@@ -16,14 +16,13 @@ class CurlResultTest extends TestCase
        {
                parent::setUp();
 
-
                /** @var Dice|MockInterface $dice */
                $dice = \Mockery::mock(Dice::class)->makePartial();
                $dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
 
                $logger = new NullLogger();
                $dice->shouldReceive('create')
-                          ->with(LoggerInterface::class)
+                          ->with(LoggerInterface::class, [])
                           ->andReturn($logger);
 
                DI::init($dice);
index 7f63027fcb7c10f8552f25157ab724a3305b7d8e..47f80f36ea83f11b11e63e0f1f6877546e412bf9 100644 (file)
@@ -2,7 +2,7 @@
 namespace Friendica\Test\src\Util;
 
 use Friendica\App\BaseURL;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Test\MockedTest;
 
 class BaseURLTest extends MockedTest
@@ -173,7 +173,7 @@ class BaseURLTest extends MockedTest
         */
        public function testCheck($server, $input, $assert)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@@ -295,7 +295,7 @@ class BaseURLTest extends MockedTest
         */
        public function testSave($input, $save, $url)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@@ -333,7 +333,7 @@ class BaseURLTest extends MockedTest
         */
        public function testSaveByUrl($input, $save, $url)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@@ -409,7 +409,7 @@ class BaseURLTest extends MockedTest
         */
        public function testGetURL($sslPolicy, $ssl, $url, $assert)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
@@ -467,7 +467,7 @@ class BaseURLTest extends MockedTest
         */
        public function testCheckRedirectHTTPS($server, $forceSSL, $sslPolicy, $url, $redirect)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
@@ -503,7 +503,7 @@ class BaseURLTest extends MockedTest
         */
        public function testWrongSave($fail)
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = \Mockery::mock(IConfiguration::class);
                $configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
                $configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
                $configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn(BaseURL::DEFAULT_SSL_SCHEME);
index 0790bc30ac3aad45da8de12d45be1bdd68e4bf0e..ba47858a0939cbcd8baa744d24f732d1ed671c95 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Test\src\Util;
 
 use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
 use Friendica\Test\MockedTest;
 use Friendica\Util\Profiler;
 use Mockery\MockInterface;
@@ -235,7 +235,7 @@ class ProfilerTest extends MockedTest
 
                $profiler->saveTimestamp(time(), 'network', 'test1');
 
-               $config = \Mockery::mock(Configuration::class);
+               $config = \Mockery::mock(IConfiguration::class);
                $config->shouldReceive('get')
                            ->with('system', 'profiler')
                            ->andReturn(false)