mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:10:10 +00:00
Refactoring Core class structures ...
This commit is contained in:
parent
57b4c008cb
commit
b216317477
130 changed files with 1625 additions and 1397 deletions
|
@ -49,7 +49,7 @@ class CacheTest extends MockedTest
|
|||
];
|
||||
}
|
||||
|
||||
private function assertConfigValues($data, Cache\Cache $configCache)
|
||||
private function assertConfigValues($data, \Friendica\Core\Config\ValueObject\Cache $configCache)
|
||||
{
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -64,7 +64,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testLoadConfigArray($data)
|
||||
{
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data);
|
||||
|
||||
self::assertConfigValues($data, $configCache);
|
||||
|
@ -83,27 +83,27 @@ class CacheTest extends MockedTest
|
|||
]
|
||||
];
|
||||
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache->load($data, Cache\Cache::SOURCE_DB);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
// doesn't override - Low Priority due Config file
|
||||
$configCache->load($override, Cache\Cache::SOURCE_FILE);
|
||||
$configCache->load($override, \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
|
||||
|
||||
self::assertConfigValues($data, $configCache);
|
||||
|
||||
// override the value - High Prio due Server Env
|
||||
$configCache->load($override, Cache\Cache::SOURCE_ENV);
|
||||
$configCache->load($override, \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV);
|
||||
|
||||
self::assertEquals($override['system']['test'], $configCache->get('system', 'test'));
|
||||
self::assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
|
||||
|
||||
// Don't overwrite server ENV variables - even in load mode
|
||||
$configCache->load($data, Cache\Cache::SOURCE_DB);
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
|
||||
self::assertEquals($override['system']['test'], $configCache->get('system', 'test'));
|
||||
self::assertEquals($override['system']['boolTrue'], $configCache->get('system', 'boolTrue'));
|
||||
|
||||
// Overwrite ENV variables with ENV variables
|
||||
$configCache->load($data, Cache\Cache::SOURCE_ENV);
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV);
|
||||
|
||||
self::assertConfigValues($data, $configCache);
|
||||
self::assertNotEquals($override['system']['test'], $configCache->get('system', 'test'));
|
||||
|
@ -115,7 +115,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testLoadConfigArrayWrong()
|
||||
{
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
// empty dataset
|
||||
$configCache->load([]);
|
||||
|
@ -136,7 +136,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetAll($data)
|
||||
{
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data);
|
||||
|
||||
$all = $configCache->getAll();
|
||||
|
@ -151,7 +151,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testSetGet($data)
|
||||
{
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -167,7 +167,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetEmpty()
|
||||
{
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
self::assertNull($configCache->get('something', 'value'));
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetCat()
|
||||
{
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'system' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
|
@ -205,7 +205,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testDelete($data)
|
||||
{
|
||||
$configCache = new Cache\Cache($data);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -222,7 +222,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testKeyDiffWithResult($data)
|
||||
{
|
||||
$configCache = new Cache\Cache($data);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
|
||||
$diffConfig = [
|
||||
'fakeCat' => [
|
||||
|
@ -239,7 +239,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testKeyDiffWithoutResult($data)
|
||||
{
|
||||
$configCache = new Cache\Cache($data);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
|
||||
$diffConfig = $configCache->getAll();
|
||||
|
||||
|
@ -251,7 +251,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testPasswordHide()
|
||||
{
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
|
@ -268,7 +268,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testPasswordShow()
|
||||
{
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
|
@ -285,7 +285,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testEmptyPassword()
|
||||
{
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'database' => [
|
||||
'password' => '',
|
||||
'username' => '',
|
||||
|
@ -299,7 +299,7 @@ class CacheTest extends MockedTest
|
|||
|
||||
public function testWrongTypePassword()
|
||||
{
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'database' => [
|
||||
'password' => new stdClass(),
|
||||
'username' => '',
|
||||
|
@ -309,7 +309,7 @@ class CacheTest extends MockedTest
|
|||
self::assertNotEmpty($configCache->get('database', 'password'));
|
||||
self::assertEmpty($configCache->get('database', 'username'));
|
||||
|
||||
$configCache = new Cache\Cache([
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
'database' => [
|
||||
'password' => 23,
|
||||
'username' => '',
|
||||
|
@ -327,19 +327,19 @@ class CacheTest extends MockedTest
|
|||
public function testSetOverrides($data)
|
||||
{
|
||||
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache->load($data, Cache\Cache::SOURCE_DB);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
|
||||
// test with wrong override
|
||||
self::assertFalse($configCache->set('system', 'test', '1234567', Cache\Cache::SOURCE_FILE));
|
||||
self::assertFalse($configCache->set('system', 'test', '1234567', \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE));
|
||||
self::assertEquals($data['system']['test'], $configCache->get('system', 'test'));
|
||||
|
||||
// test with override (equal)
|
||||
self::assertTrue($configCache->set('system', 'test', '8910', Cache\Cache::SOURCE_DB));
|
||||
self::assertTrue($configCache->set('system', 'test', '8910', \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB));
|
||||
self::assertEquals('8910', $configCache->get('system', 'test'));
|
||||
|
||||
// test with override (over)
|
||||
self::assertTrue($configCache->set('system', 'test', '111213', Cache\Cache::SOURCE_ENV));
|
||||
self::assertTrue($configCache->set('system', 'test', '111213', \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV));
|
||||
self::assertEquals('111213', $configCache->get('system', 'test'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
namespace Friendica\Test\src\Core\Config\Cache;
|
||||
|
||||
use Friendica\Core\Config\Cache;
|
||||
use Friendica\Core\Config\Factory\ConfigFactory;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Core\Config\Cache\ConfigFileLoader;
|
||||
use Friendica\Core\Config\Util\ConfigFileLoader;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class ConfigFileLoaderTest extends MockedTest
|
||||
|
@ -48,10 +48,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -74,10 +74,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
}
|
||||
|
@ -103,10 +103,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -140,10 +140,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -174,12 +174,12 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root)
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new \Friendica\Core\Config\Util\ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -228,10 +228,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('addon')->getChild('test')->getChild('config'))
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new \Friendica\Core\Config\Util\ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
|
||||
$conf = $configFileLoader->loadAddonConfig('test');
|
||||
|
@ -265,12 +265,12 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.config.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new \Friendica\Core\Config\Util\ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -299,12 +299,12 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.ini.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new \Friendica\Core\Config\Util\ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -333,12 +333,12 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.ini.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new \Friendica\Core\Config\Util\ConfigFileLoader(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . ConfigFactory::STATIC_DIR
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache\Cache();
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -353,8 +353,8 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
{
|
||||
$this->delConfigFile('local.config.php');
|
||||
|
||||
$configFileLoader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), ['FRIENDICA_CONFIG_DIR' => '/a/wrong/dir/']);
|
||||
$configCache = new Cache\Cache();
|
||||
$configFileLoader = (new Config())->createConfigFileLoader($this->root->url(), ['FRIENDICA_CONFIG_DIR' => '/a/wrong/dir/']);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -379,8 +379,8 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config2'))
|
||||
->setContent(file_get_contents($fileDir . 'B.config.php'));
|
||||
|
||||
$configFileLoader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), ['FRIENDICA_CONFIG_DIR' => $this->root->getChild('config2')->url()]);
|
||||
$configCache = new Cache\Cache();
|
||||
$configFileLoader = (new Config())->createConfigFileLoader($this->root->url(), ['FRIENDICA_CONFIG_DIR' => $this->root->getChild('config2')->url()]);
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue