Splitting ConfigCache & PConfigCache
- Remove IConfigCache & IPConfigCache - Add new PConfigCache - Add missing Logger::init() (bugfixing tests)
This commit is contained in:
parent
b56709d802
commit
c82127ffb7
|
@ -8,7 +8,7 @@ use Detection\MobileDetect;
|
|||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use Exception;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Theme;
|
||||
|
@ -131,7 +131,7 @@ class App
|
|||
/**
|
||||
* Returns the current config cache of this node
|
||||
*
|
||||
* @return IConfigCache
|
||||
* @return ConfigCache
|
||||
*/
|
||||
public function getConfigCache()
|
||||
{
|
||||
|
|
|
@ -207,12 +207,12 @@ HELP;
|
|||
|
||||
/**
|
||||
* @param Installer $installer The Installer instance
|
||||
* @param Config\Cache\IConfigCache $configCache The config cache
|
||||
* @param Config\Cache\ConfigCache $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\IConfigCache $configCache)
|
||||
private function runBasicChecks(Installer $installer, Config\Cache\ConfigCache $configCache)
|
||||
{
|
||||
$checked = true;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use ParagonIE\HiddenString\HiddenString;
|
|||
* Initial, all *.config.php files are loaded into this cache with the
|
||||
* ConfigFileLoader ( @see ConfigFileLoader )
|
||||
*/
|
||||
class ConfigCache implements IConfigCache, IPConfigCache
|
||||
class ConfigCache
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
|
@ -22,7 +22,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
private $hidePasswordOutput;
|
||||
|
||||
/**
|
||||
* @param array $config A initial config array
|
||||
* @param array $config A initial config array
|
||||
* @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
|
||||
*/
|
||||
public function __construct(array $config = [], $hidePasswordOutput = true)
|
||||
|
@ -32,7 +32,11 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Tries to load the specified configuration array into the config array.
|
||||
* Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
|
||||
*
|
||||
* @param array $config
|
||||
* @param bool $overwrite Force value overwrite if the config key already exists
|
||||
*/
|
||||
public function load(array $config, $overwrite = false)
|
||||
{
|
||||
|
@ -57,7 +61,12 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Gets a value from the config cache.
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return null|mixed Returns the value of the Config entry or null if not set
|
||||
*/
|
||||
public function get($cat, $key = null)
|
||||
{
|
||||
|
@ -85,7 +94,13 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Sets a value in the config cache. Accepts raw output from the config table
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
* @param mixed $value Value to set
|
||||
*
|
||||
* @return bool True, if the value is set
|
||||
*/
|
||||
public function set($cat, $key, $value)
|
||||
{
|
||||
|
@ -104,7 +119,12 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Deletes a value from the config cache.
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return bool true, if deleted
|
||||
*/
|
||||
public function delete($cat, $key)
|
||||
{
|
||||
|
@ -119,80 +139,6 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadP($uid, array $config)
|
||||
{
|
||||
$categories = array_keys($config);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if (isset($config[$category]) && is_array($config[$category])) {
|
||||
|
||||
$keys = array_keys($config[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$value = $config[$category][$key];
|
||||
if (isset($value)) {
|
||||
$this->setP($uid, $category, $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getP($uid, $cat, $key = null)
|
||||
{
|
||||
if (isset($this->config[$uid][$cat][$key])) {
|
||||
return $this->config[$uid][$cat][$key];
|
||||
} elseif (!isset($key) && isset($this->config[$uid][$cat])) {
|
||||
return $this->config[$uid][$cat];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setP($uid, $cat, $key, $value)
|
||||
{
|
||||
if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) {
|
||||
$this->config[$uid] = [];
|
||||
}
|
||||
|
||||
if (!isset($this->config[$uid][$cat])) {
|
||||
$this->config[$uid][$cat] = [];
|
||||
}
|
||||
|
||||
$this->config[$uid][$cat][$key] = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteP($uid, $cat, $key)
|
||||
{
|
||||
if (isset($this->config[$uid][$cat][$key])) {
|
||||
unset($this->config[$uid][$cat][$key]);
|
||||
if (count($this->config[$uid][$cat]) == 0) {
|
||||
unset($this->config[$uid][$cat]);
|
||||
if (count($this->config[$uid]) == 0) {
|
||||
unset($this->config[$uid]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the whole configuration
|
||||
*
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Core\Config\Cache;
|
||||
|
||||
/**
|
||||
* The interface for a system-wide ConfigCache
|
||||
*/
|
||||
interface IConfigCache
|
||||
{
|
||||
/**
|
||||
* Tries to load the specified configuration array into the config array.
|
||||
* Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
|
||||
*
|
||||
* @param array $config
|
||||
* @param bool $overwrite Force value overwrite if the config key already exists
|
||||
*/
|
||||
function load(array $config, $overwrite = false);
|
||||
|
||||
/**
|
||||
* Gets a value from the config cache.
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return null|mixed Returns the value of the Config entry or null if not set
|
||||
*/
|
||||
function get($cat, $key = null);
|
||||
|
||||
/**
|
||||
* Sets a value in the config cache. Accepts raw output from the config table
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
* @param mixed $value Value to set
|
||||
*
|
||||
* @return bool True, if the value is set
|
||||
*/
|
||||
function set($cat, $key, $value);
|
||||
|
||||
/**
|
||||
* Deletes a value from the config cache.
|
||||
*
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return bool true, if deleted
|
||||
*/
|
||||
function delete($cat, $key);
|
||||
|
||||
/**
|
||||
* Returns the whole configuration cache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getAll();
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Core\Config\Cache;
|
||||
|
||||
/**
|
||||
* The interface for a user-specific config cache
|
||||
*/
|
||||
interface IPConfigCache
|
||||
{
|
||||
/**
|
||||
* Tries to load the specified configuration array into the user specific config array.
|
||||
* Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param array $config
|
||||
*/
|
||||
function loadP($uid, array $config);
|
||||
|
||||
/**
|
||||
* Retrieves a value from the user config cache
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return null|string The value of the config entry or null if not set
|
||||
*/
|
||||
function getP($uid, $cat, $key = null);
|
||||
|
||||
/**
|
||||
* Sets a value in the user config cache
|
||||
*
|
||||
* Accepts raw output from the pconfig table
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
* @param mixed $value Value to set
|
||||
*/
|
||||
function setP($uid, $cat, $key, $value);
|
||||
|
||||
/**
|
||||
* Deletes a value from the user config cache
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return bool true, if deleted
|
||||
*/
|
||||
function deleteP($uid, $cat, $key);
|
||||
|
||||
/**
|
||||
* Returns the whole configuration cache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getAll();
|
||||
}
|
173
src/Core/Config/Cache/PConfigCache.php
Normal file
173
src/Core/Config/Cache/PConfigCache.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Core\Config\Cache;
|
||||
|
||||
use ParagonIE\HiddenString\HiddenString;
|
||||
|
||||
/**
|
||||
* The Friendica config cache for users
|
||||
*/
|
||||
class PConfigCache
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hidePasswordOutput;
|
||||
|
||||
/**
|
||||
* @param bool $hidePasswordOutput True, if cache variables should take extra care of password values
|
||||
*/
|
||||
public function __construct($hidePasswordOutput = true)
|
||||
{
|
||||
$this->hidePasswordOutput = $hidePasswordOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to load the specified configuration array into the user specific config array.
|
||||
* Doesn't overwrite previously set values by default to prevent default config files to supersede DB Config.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param array $config
|
||||
*/
|
||||
public function load($uid, array $config)
|
||||
{
|
||||
$categories = array_keys($config);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if (isset($config[$category]) && is_array($config[$category])) {
|
||||
|
||||
$keys = array_keys($config[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$value = $config[$category][$key];
|
||||
if (isset($value)) {
|
||||
$this->set($uid, $category, $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a value from the user config cache
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return null|string The value of the config entry or null if not set
|
||||
*/
|
||||
public function get($uid, $cat, $key = null)
|
||||
{
|
||||
if (isset($this->config[$uid][$cat][$key])) {
|
||||
return $this->config[$uid][$cat][$key];
|
||||
} elseif (!isset($key) && isset($this->config[$uid][$cat])) {
|
||||
return $this->config[$uid][$cat];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value in the user config cache
|
||||
*
|
||||
* Accepts raw output from the pconfig table
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
* @param mixed $value Value to set
|
||||
*
|
||||
* @return bool Set successful
|
||||
*/
|
||||
public function set($uid, $cat, $key, $value)
|
||||
{
|
||||
if (!isset($this->config[$uid]) || !is_array($this->config[$uid])) {
|
||||
$this->config[$uid] = [];
|
||||
}
|
||||
|
||||
if (!isset($this->config[$uid][$cat])) {
|
||||
$this->config[$uid][$cat] = [];
|
||||
}
|
||||
|
||||
if ($this->hidePasswordOutput &&
|
||||
$key == 'password' &&
|
||||
!empty($value) && is_string($value)) {
|
||||
$this->config[$uid][$cat][$key] = new HiddenString((string) $value);
|
||||
} else {
|
||||
$this->config[$uid][$cat][$key] = $value;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a value from the user config cache
|
||||
*
|
||||
* @param int $uid User Id
|
||||
* @param string $cat Config category
|
||||
* @param string $key Config key
|
||||
*
|
||||
* @return bool true, if deleted
|
||||
*/
|
||||
public function delete($uid, $cat, $key)
|
||||
{
|
||||
if (isset($this->config[$uid][$cat][$key])) {
|
||||
unset($this->config[$uid][$cat][$key]);
|
||||
if (count($this->config[$uid][$cat]) == 0) {
|
||||
unset($this->config[$uid][$cat]);
|
||||
if (count($this->config[$uid]) == 0) {
|
||||
unset($this->config[$uid]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the whole configuration
|
||||
*
|
||||
* @return array The configuration
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with missing categories/Keys
|
||||
*
|
||||
* @param array $config The array to check
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function keyDiff(array $config)
|
||||
{
|
||||
$return = [];
|
||||
|
||||
$categories = array_keys($config);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if (is_array($config[$category])) {
|
||||
$keys = array_keys($config[$category]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($this->config[$category][$key])) {
|
||||
$return[$category][$key] = $config[$category][$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace Friendica\Core\Config;
|
|||
class Configuration
|
||||
{
|
||||
/**
|
||||
* @var Cache\IConfigCache
|
||||
* @var Cache\ConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
|
||||
|
@ -21,10 +21,10 @@ class Configuration
|
|||
private $configAdapter;
|
||||
|
||||
/**
|
||||
* @param Cache\IConfigCache $configCache The configuration cache (based on the config-files)
|
||||
* @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
|
||||
* @param Adapter\IConfigAdapter $configAdapter The configuration DB-backend
|
||||
*/
|
||||
public function __construct(Cache\IConfigCache $configCache, Adapter\IConfigAdapter $configAdapter)
|
||||
public function __construct(Cache\ConfigCache $configCache, Adapter\IConfigAdapter $configAdapter)
|
||||
{
|
||||
$this->configCache = $configCache;
|
||||
$this->configAdapter = $configAdapter;
|
||||
|
@ -35,7 +35,7 @@ class Configuration
|
|||
/**
|
||||
* Returns the Config Cache
|
||||
*
|
||||
* @return Cache\IConfigCache
|
||||
* @return Cache\ConfigCache
|
||||
*/
|
||||
public function getCache()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Friendica\Core\Config;
|
|||
class PConfiguration
|
||||
{
|
||||
/**
|
||||
* @var Cache\IPConfigCache
|
||||
* @var Cache\PConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
|
||||
|
@ -22,10 +22,10 @@ class PConfiguration
|
|||
private $configAdapter;
|
||||
|
||||
/**
|
||||
* @param Cache\IPConfigCache $configCache The configuration cache
|
||||
* @param Cache\PConfigCache $configCache The configuration cache
|
||||
* @param Adapter\IPConfigAdapter $configAdapter The configuration DB-backend
|
||||
*/
|
||||
public function __construct(Cache\IPConfigCache $configCache, Adapter\IPConfigAdapter $configAdapter)
|
||||
public function __construct(Cache\PConfigCache $configCache, Adapter\IPConfigAdapter $configAdapter)
|
||||
{
|
||||
$this->configCache = $configCache;
|
||||
$this->configAdapter = $configAdapter;
|
||||
|
@ -50,7 +50,7 @@ class PConfiguration
|
|||
}
|
||||
|
||||
// load the whole category out of the DB into the cache
|
||||
$this->configCache->loadP($uid, $this->configAdapter->load($uid, $cat));
|
||||
$this->configCache->load($uid, $this->configAdapter->load($uid, $cat));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,13 +78,13 @@ class PConfiguration
|
|||
$dbValue = $this->configAdapter->get($uid, $cat, $key);
|
||||
|
||||
if (isset($dbValue)) {
|
||||
$this->configCache->setP($uid, $cat, $key, $dbValue);
|
||||
$this->configCache->set($uid, $cat, $key, $dbValue);
|
||||
return $dbValue;
|
||||
}
|
||||
}
|
||||
|
||||
// use the config cache for return
|
||||
$result = $this->configCache->getP($uid, $cat, $key);
|
||||
$result = $this->configCache->get($uid, $cat, $key);
|
||||
return (isset($result)) ? $result : $default_value;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class PConfiguration
|
|||
public function set($uid, $cat, $key, $value)
|
||||
{
|
||||
// set the cache first
|
||||
$cached = $this->configCache->setP($uid, $cat, $key, $value);
|
||||
$cached = $this->configCache->set($uid, $cat, $key, $value);
|
||||
|
||||
// If there is no connected adapter, we're finished
|
||||
if (!$this->configAdapter->isConnected()) {
|
||||
|
@ -133,7 +133,7 @@ class PConfiguration
|
|||
*/
|
||||
public function delete($uid, $cat, $key)
|
||||
{
|
||||
$cacheRemoved = $this->configCache->deleteP($uid, $cat, $key);
|
||||
$cacheRemoved = $this->configCache->delete($uid, $cat, $key);
|
||||
|
||||
if (!$this->configAdapter->isConnected()) {
|
||||
return $cacheRemoved;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Friendica\Core;
|
|||
|
||||
use DOMDocument;
|
||||
use Exception;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Factory\DBFactory;
|
||||
use Friendica\Object\Image;
|
||||
|
@ -130,12 +130,12 @@ class Installer
|
|||
* - Creates `config/local.config.php`
|
||||
* - Installs Database Structure
|
||||
*
|
||||
* @param IConfigCache $configCache The config cache with all config relevant information
|
||||
* @param ConfigCache $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(IConfigCache $configCache)
|
||||
public function createConfig(ConfigCache $configCache)
|
||||
{
|
||||
$basepath = $configCache->get('system', 'basepath');
|
||||
|
||||
|
@ -592,13 +592,13 @@ class Installer
|
|||
/**
|
||||
* Checking the Database connection and if it is available for the current installation
|
||||
*
|
||||
* @param IConfigCache $configCache The configuration cache
|
||||
* @param ConfigCache $configCache The configuration cache
|
||||
* @param Profiler $profiler The profiler of this app
|
||||
*
|
||||
* @return bool true if the check was successful, otherwise false
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkDB(IConfigCache $configCache, Profiler $profiler)
|
||||
public function checkDB(ConfigCache $configCache, Profiler $profiler)
|
||||
{
|
||||
$database = DBFactory::init($configCache, $profiler, [], new VoidLogger());
|
||||
|
||||
|
@ -620,12 +620,12 @@ class Installer
|
|||
/**
|
||||
* Setup the default cache for a new installation
|
||||
*
|
||||
* @param IConfigCache $configCache The configuration cache
|
||||
* @param ConfigCache $configCache The configuration cache
|
||||
* @param string $basePath The determined basepath
|
||||
*
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function setUpCache(IConfigCache $configCache, $basePath)
|
||||
public function setUpCache(ConfigCache $configCache, $basePath)
|
||||
{
|
||||
$configCache->set('config', 'php_path' , $this->getPHPPath());
|
||||
$configCache->set('system', 'basepath' , $basePath);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Friendica\Database;
|
||||
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
|
@ -25,7 +25,7 @@ class Database
|
|||
private $connected = false;
|
||||
|
||||
/**
|
||||
* @var IConfigCache
|
||||
* @var ConfigCache
|
||||
*/
|
||||
private $configCache;
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ class Database
|
|||
private $db_name;
|
||||
private $db_charset;
|
||||
|
||||
public function __construct(IConfigCache $configCache, Profiler $profiler, LoggerInterface $logger, $serveraddr, $user, HiddenString $pass, $db, $charset = null)
|
||||
public function __construct(ConfigCache $configCache, Profiler $profiler, LoggerInterface $logger, $serveraddr, $user, HiddenString $pass, $db, $charset = null)
|
||||
{
|
||||
// We are storing these values for being able to perform a reconnect
|
||||
$this->configCache = $configCache;
|
||||
|
|
|
@ -45,12 +45,12 @@ class ConfigFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Cache\ConfigCache $configCache The config cache of this adapter
|
||||
* @param Cache\PConfigCache $configCache The config cache of this adapter
|
||||
* @param int $uid The UID of the current user
|
||||
*
|
||||
* @return Config\PConfiguration
|
||||
*/
|
||||
public static function createPConfig(Cache\ConfigCache $configCache, $uid = null)
|
||||
public static function createPConfig(Cache\PConfigCache $configCache, $uid = null)
|
||||
{
|
||||
if ($configCache->get('system', 'config_adapter') === 'preload') {
|
||||
$configAdapter = new Adapter\PreloadPConfigAdapter($uid);
|
||||
|
|
|
@ -13,14 +13,14 @@ class DBFactory
|
|||
/**
|
||||
* Initialize the DBA connection
|
||||
*
|
||||
* @param Cache\IConfigCache $configCache The configuration cache
|
||||
* @param Profiler $profiler The profiler
|
||||
* @param array $server The $_SERVER variables
|
||||
* @param Cache\ConfigCache $configCache The configuration cache
|
||||
* @param Profiler $profiler The profiler
|
||||
* @param array $server The $_SERVER variables
|
||||
*
|
||||
* @return Database\Database
|
||||
* @throws \Exception if connection went bad
|
||||
*/
|
||||
public static function init(Cache\IConfigCache $configCache, Profiler $profiler, array $server)
|
||||
public static function init(Cache\ConfigCache $configCache, Profiler $profiler, array $server)
|
||||
{
|
||||
$db_host = $configCache->get('database', 'hostname');
|
||||
$db_user = $configCache->get('database', 'username');
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Friendica\Factory;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Cache\PConfigCache;
|
||||
use Friendica\Factory;
|
||||
use Friendica\Util\BasePath;
|
||||
use Friendica\Util\BaseURL;
|
||||
|
@ -32,7 +33,7 @@ class DependencyFactory
|
|||
$database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
|
||||
$config = Factory\ConfigFactory::createConfig($configCache);
|
||||
// needed to call PConfig::init()
|
||||
Factory\ConfigFactory::createPConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig(new PConfigCache());
|
||||
$logger = Factory\LoggerFactory::create($channel, $database, $config, $profiler);
|
||||
Factory\LoggerFactory::createDev($channel, $config, $profiler);
|
||||
$baseURL = new BaseURL($config, $_SERVER);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Friendica\Factory;
|
||||
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Util\Profiler;
|
||||
|
||||
class ProfilerFactory
|
||||
|
@ -10,11 +10,11 @@ class ProfilerFactory
|
|||
/**
|
||||
* Creates a Profiler for the current execution
|
||||
*
|
||||
* @param IConfigCache $configCache The configuration cache
|
||||
* @param ConfigCache $configCache The configuration cache
|
||||
*
|
||||
* @return Profiler
|
||||
*/
|
||||
public static function create(IConfigCache $configCache)
|
||||
public static function create(ConfigCache $configCache)
|
||||
{
|
||||
$enabled = $configCache->get('system', 'profiler');
|
||||
$enabled = isset($enabled) && $enabled !== '0';
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Friendica\Module;
|
|||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Util\BasePath;
|
||||
|
@ -334,13 +333,13 @@ class Install extends BaseModule
|
|||
/**
|
||||
* Checks the $_POST settings and updates the config Cache for it
|
||||
*
|
||||
* @param IConfigCache $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
|
||||
* @param Core\Config\Cache\ConfigCache $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(IConfigCache $configCache, array $post, $cat, $key, $default = null)
|
||||
private static function checkSetting(Core\Config\Cache\ConfigCache $configCache, array $post, $cat, $key, $default = null)
|
||||
{
|
||||
$configCache->set($cat, $key,
|
||||
Strings::escapeTags(
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace Friendica\Util\Config;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
|
||||
/**
|
||||
* The ConfigFileLoader loads config-files and stores them in a IConfigCache ( @see IConfigCache )
|
||||
* The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache )
|
||||
*
|
||||
* It is capable of loading the following config files:
|
||||
* - *.config.php (current)
|
||||
|
@ -33,12 +33,12 @@ class ConfigFileLoader extends ConfigFileManager
|
|||
* First loads the default value for all the configuration keys, then the legacy configuration files, then the
|
||||
* expected local.config.php
|
||||
*
|
||||
* @param IConfigCache $config The config cache to load to
|
||||
* @param bool $raw Setup the raw config format
|
||||
* @param ConfigCache $config The config cache to load to
|
||||
* @param bool $raw Setup the raw config format
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setupCache(IConfigCache $config, $raw = false)
|
||||
public function setupCache(ConfigCache $config, $raw = false)
|
||||
{
|
||||
$config->load($this->loadCoreConfig('defaults'));
|
||||
$config->load($this->loadCoreConfig('settings'));
|
||||
|
|
|
@ -43,7 +43,7 @@ trait AppMockTrait
|
|||
*/
|
||||
public function mockApp(vfsStreamDirectory $root, $raw = false)
|
||||
{
|
||||
$this->configMock = \Mockery::mock(Config\Cache\IConfigCache::class);
|
||||
$this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
|
||||
$this->mode = \Mockery::mock(App\Mode::class);
|
||||
$configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class);
|
||||
// Disable the adapter
|
||||
|
|
|
@ -57,7 +57,7 @@ class ApiTest extends DatabaseTest
|
|||
$profiler = Factory\ProfilerFactory::create($configCache);
|
||||
$database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
|
||||
$config = Factory\ConfigFactory::createConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig(new Config\Cache\PConfigCache());
|
||||
$logger = Factory\LoggerFactory::create('test', $database, $config, $profiler);
|
||||
$baseUrl = new BaseURL($config, $_SERVER);
|
||||
$this->app = new App($database, $config, $mode, $router, $baseUrl, $logger, $profiler, false);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Friendica\Test\src\Core\Cache;
|
||||
|
||||
use Friendica\Core\Cache\IMemoryCacheDriver;
|
||||
use Friendica\Core\Logger;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
abstract class MemoryCacheTest extends CacheTest
|
||||
{
|
||||
|
@ -13,6 +15,8 @@ abstract class MemoryCacheTest extends CacheTest
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
Logger::init(new NullLogger());
|
||||
|
||||
parent::setUp();
|
||||
if (!($this->instance instanceof IMemoryCacheDriver)) {
|
||||
throw new \Exception('MemoryCacheTest unsupported');
|
||||
|
|
|
@ -29,15 +29,11 @@ class ConfigCacheTest extends MockedTest
|
|||
];
|
||||
}
|
||||
|
||||
private function assertConfigValues($data, ConfigCache $configCache, $uid = null)
|
||||
private function assertConfigValues($data, ConfigCache $configCache)
|
||||
{
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
if (isset($uid)) {
|
||||
$this->assertEquals($data[$cat][$key], $configCache->getP($uid, $cat, $key));
|
||||
} else {
|
||||
$this->assertEquals($data[$cat][$key], $configCache->get($cat, $key));
|
||||
}
|
||||
$this->assertEquals($data[$cat][$key], $configCache->get($cat, $key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,73 +176,6 @@ class ConfigCacheTest extends MockedTest
|
|||
$this->assertEmpty($configCache->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the setP() and getP() methods
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGetP($data)
|
||||
{
|
||||
$configCache = new ConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->setP($uid, $cat, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertConfigValues($data, $configCache, $uid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the getP() method with a category
|
||||
*/
|
||||
public function testGetPCat()
|
||||
{
|
||||
$configCache = new ConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
$configCache->loadP($uid, [
|
||||
'system' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
],
|
||||
'config' => [
|
||||
'key3' => 'value3',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals([
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
], $configCache->get($uid, 'system'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the deleteP() method
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testDeleteP($data)
|
||||
{
|
||||
$configCache = new ConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->setP($uid, $cat, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->deleteP($uid, $cat, $key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEmpty($configCache->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the keyDiff() method with result
|
||||
* @dataProvider dataTests
|
||||
|
|
252
tests/src/Core/Config/Cache/PConfigCacheTest.php
Normal file
252
tests/src/Core/Config/Cache/PConfigCacheTest.php
Normal file
|
@ -0,0 +1,252 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Core\Config\Cache;
|
||||
|
||||
use Friendica\Core\Config\Cache\PConfigCache;
|
||||
use Friendica\Test\MockedTest;
|
||||
|
||||
class PConfigCacheTest extends MockedTest
|
||||
{
|
||||
public function dataTests()
|
||||
{
|
||||
return [
|
||||
'normal' => [
|
||||
'data' => [
|
||||
'system' => [
|
||||
'test' => 'it',
|
||||
'boolTrue' => true,
|
||||
'boolFalse' => false,
|
||||
'int' => 235,
|
||||
'dec' => 2.456,
|
||||
'array' => ['1', 2, '3', true, false],
|
||||
],
|
||||
'config' => [
|
||||
'a' => 'value',
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
private function assertConfigValues($data, PConfigCache $configCache, $uid)
|
||||
{
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$this->assertEquals($data[$cat][$key], $configCache->get($uid, $cat, $key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the setP() and getP() methods
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGet($data)
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->set($uid, $cat, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertConfigValues($data, $configCache, $uid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the getP() method with a category
|
||||
*/
|
||||
public function testGetCat()
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
$configCache->load($uid, [
|
||||
'system' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
],
|
||||
'config' => [
|
||||
'key3' => 'value3',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals([
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
], $configCache->get($uid, 'system'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the deleteP() method
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testDelete($data)
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
$uid = 345;
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->set($uid, $cat, $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$configCache->delete($uid, $cat, $key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEmpty($configCache->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the keyDiff() method with result
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testKeyDiffWithResult($data)
|
||||
{
|
||||
$configCache = new PConfigCache($data);
|
||||
|
||||
$diffConfig = [
|
||||
'fakeCat' => [
|
||||
'fakeKey' => 'value',
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertEquals($diffConfig, $configCache->keyDiff($diffConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the keyDiff() method without result
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testKeyDiffWithoutResult($data)
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, $data);
|
||||
|
||||
$diffConfig = $configCache->getAll();
|
||||
|
||||
$this->assertEmpty($configCache->keyDiff($diffConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the default hiding of passwords inside the cache
|
||||
*/
|
||||
public function testPasswordHide()
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, [
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
|
||||
$this->assertNotEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
|
||||
$this->assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test disabling the hiding of passwords inside the cache
|
||||
*/
|
||||
public function testPasswordShow()
|
||||
{
|
||||
$configCache = new PConfigCache(false);
|
||||
|
||||
$configCache->load(1, [
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals('supersecure', $configCache->get(1, 'database', 'password'));
|
||||
$this->assertEquals('supersecure', print_r($configCache->get(1, 'database', 'password'), true));
|
||||
$this->assertEquals('notsecured', print_r($configCache->get(1, 'database', 'username'), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a empty password
|
||||
*/
|
||||
public function testEmptyPassword()
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, [
|
||||
'database' => [
|
||||
'password' => '',
|
||||
'username' => '',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEmpty($configCache->get(1, 'database', 'password'));
|
||||
$this->assertEmpty($configCache->get(1, 'database', 'username'));
|
||||
}
|
||||
|
||||
public function testWrongTypePassword()
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, [
|
||||
'database' => [
|
||||
'password' => new \stdClass(),
|
||||
'username' => '',
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($configCache->get(1, 'database', 'password'));
|
||||
$this->assertEmpty($configCache->get(1, 'database', 'username'));
|
||||
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, [
|
||||
'database' => [
|
||||
'password' => 23,
|
||||
'username' => '',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(23, $configCache->get(1, 'database', 'password'));
|
||||
$this->assertEmpty($configCache->get(1, 'database', 'username'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test two different UID configs and make sure that there is no overlapping possible
|
||||
*/
|
||||
public function testTwoUid()
|
||||
{
|
||||
$configCache = new PConfigCache();
|
||||
|
||||
$configCache->load(1, [
|
||||
'cat1' => [
|
||||
'key1' => 'value1',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
$configCache->load(2, [
|
||||
'cat2' => [
|
||||
'key2' => 'value2',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals('value1', $configCache->get(1, 'cat1', 'key1'));
|
||||
$this->assertEquals('value2', $configCache->get(2, 'cat2', 'key2'));
|
||||
|
||||
$this->assertNull($configCache->get(1, 'cat2', 'key2'));
|
||||
$this->assertNull($configCache->get(2, 'cat1', 'key1'));
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ namespace Friendica\Test\src\Core\Config;
|
|||
|
||||
use Friendica\Core\Config\Adapter\IConfigAdapter;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Configuration;
|
||||
use Friendica\Test\MockedTest;
|
||||
|
||||
|
@ -35,7 +34,7 @@ class ConfigurationTest extends MockedTest
|
|||
|
||||
$configuration = new Configuration($configCache, $configAdapter);
|
||||
|
||||
$this->assertInstanceOf(IConfigCache::class, $configuration->getCache());
|
||||
$this->assertInstanceOf(ConfigCache::class, $configuration->getCache());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Friendica\Test\src\Core\Config;
|
||||
|
||||
use Friendica\Core\Config\Adapter\IPConfigAdapter;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Core\Config\Cache\PConfigCache;
|
||||
use Friendica\Core\Config\PConfiguration;
|
||||
use Friendica\Test\MockedTest;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testCacheLoad()
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->twice();
|
||||
// expected loading
|
||||
|
@ -51,7 +51,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testCacheLoadDouble()
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4);
|
||||
// expected loading
|
||||
|
@ -77,7 +77,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testSetGetWithoutDB($data)
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(false)->times(2);
|
||||
|
||||
|
@ -95,7 +95,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testSetGetWithDB($data)
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->times(2);
|
||||
$configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(true)->once();
|
||||
|
@ -114,7 +114,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testGetWrongWithoutDB()
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(false)->times(3);
|
||||
|
||||
|
@ -137,7 +137,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testGetWithRefresh($data)
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->times(4);
|
||||
$configAdapter->shouldReceive('isLoaded')->with($uid, 'test', 'it')->andReturn(false)->once();
|
||||
|
@ -168,7 +168,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testGetWithoutLoaded($data)
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->times(3);
|
||||
|
||||
|
@ -199,7 +199,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testDeleteWithoutDB($data)
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(false)->times(4);
|
||||
|
||||
|
@ -218,7 +218,7 @@ class PConfigurationTest extends MockedTest
|
|||
public function testDeleteWithDB()
|
||||
{
|
||||
$uid = 234;
|
||||
$configCache = new ConfigCache();
|
||||
$configCache = new PConfigCache();
|
||||
$configAdapter = \Mockery::mock(IPConfigAdapter::class);
|
||||
$configAdapter->shouldReceive('isConnected')->andReturn(true)->times(6);
|
||||
$configAdapter->shouldReceive('set')->with($uid, 'test', 'it', 'now')->andReturn(false)->once();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// this is in the same namespace as Install for mocking 'function_exists'
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Core\Config\Cache\IConfigCache;
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Network\CurlResult;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Test\MockedTest;
|
||||
|
@ -402,7 +402,7 @@ class InstallerTest extends MockedTest
|
|||
$this->mockL10nT();
|
||||
|
||||
$install = new Installer();
|
||||
$configCache = \Mockery::mock(IConfigCache::class);
|
||||
$configCache = \Mockery::mock(ConfigCache::class);
|
||||
$configCache->shouldReceive('set')->with('config', 'php_path', \Mockery::any())->once();
|
||||
$configCache->shouldReceive('set')->with('system', 'basepath', '/test/')->once();
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Lock;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\AppMockTrait;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
abstract class LockTest extends MockedTest
|
||||
{
|
||||
|
@ -32,6 +34,8 @@ abstract class LockTest extends MockedTest
|
|||
->shouldReceive('getHostname')
|
||||
->andReturn('friendica.local');
|
||||
|
||||
Logger::init(new NullLogger());
|
||||
|
||||
parent::setUp();
|
||||
$this->instance = $this->getInstance();
|
||||
$this->instance->releaseAll();
|
||||
|
|
|
@ -22,7 +22,7 @@ class DBATest extends DatabaseTest
|
|||
$profiler = Factory\ProfilerFactory::create($configCache);
|
||||
$database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
|
||||
$config = Factory\ConfigFactory::createConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig(new Config\Cache\PConfigCache());
|
||||
$logger = Factory\LoggerFactory::create('test', $database, $config, $profiler);
|
||||
$baseUrl = new BaseURL($config, $_SERVER);
|
||||
$this->app = new App($database, $config, $mode, $router, $baseUrl, $logger, $profiler, false);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Friendica\Test\src\Database;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Cache\PConfigCache;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\Factory;
|
||||
use Friendica\Test\DatabaseTest;
|
||||
|
@ -22,7 +23,7 @@ class DBStructureTest extends DatabaseTest
|
|||
$profiler = Factory\ProfilerFactory::create($configCache);
|
||||
$database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
|
||||
$config = Factory\ConfigFactory::createConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig($configCache);
|
||||
Factory\ConfigFactory::createPConfig(new PConfigCache());
|
||||
$logger = Factory\LoggerFactory::create('test', $database, $config, $profiler);
|
||||
$baseUrl = new BaseURL($config, $_SERVER);
|
||||
$this->app = new App($database, $config, $mode, $router, $baseUrl, $logger, $profiler, false);
|
||||
|
|
Loading…
Reference in a new issue