Revert node.config.php into Config table

This commit is contained in:
Philipp 2023-02-05 00:15:01 +01:00
parent 6db89adc04
commit 513ef03421
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
27 changed files with 425 additions and 829 deletions

View file

@ -392,91 +392,6 @@ class ConfigFileManagerTest extends MockedTest
self::assertEquals('newValue', $configCache->get('system', 'newKey'));
}
public function testSaveData()
{
$this->delConfigFile('local.config.php');
$fileDir = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR;
vfsStream::newFile('B.config.php')
->at($this->root->getChild('config2'))
->setContent(file_get_contents($fileDir . 'B.config.php'));
$configFileManager = (new Config())->createConfigFileManager($this->root->url(),
[
'FRIENDICA_CONFIG_DIR' => $this->root->getChild('config2')->url(),
]);
$configCache = new Cache();
$configFileManager->setupCache($configCache);
$specialChars = '!"§$%&/()(/&%$\'><?$a,;:[]}{}\\?¿¿ß';
// overwrite some data and save it back to the config file
$configCache->set('system', 'test', 'it', Cache::SOURCE_DATA);
$configCache->set('config', 'test', 'it', Cache::SOURCE_DATA);
$configCache->set('system', 'test_2', 2, Cache::SOURCE_DATA);
$configCache->set('special_chars', 'special', $specialChars, Cache::SOURCE_DATA);
$configFileManager->saveData($configCache);
// Reload the configCache with the new values
$configCache2 = new Cache();
$configFileManager->setupCache($configCache2);
self::assertEquals($configCache, $configCache2);
self::assertEquals([
'system' => [
'test' => 'it',
'test_2' => 2
],
'config' => [
'test' => 'it',
],
'special_chars' => [
'special' => $specialChars,
]], $configCache2->getDataBySource(Cache::SOURCE_DATA));
}
/**
* If we delete something with the Cache::delete() functionality, be sure to probably reset it to the underlying key
*/
public function testDeleteKeyOverwrite()
{
$this->delConfigFile('node.config.php');
$fileDir = dirname(__DIR__) . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'datasets' . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR;
vfsStream::newFile('B.config.php')
->at($this->root->getChild('config'))
->setContent(file_get_contents($fileDir . 'B.config.php'));
$configFileManager = (new Config())->createConfigFileManager($this->root->url());
$configCache = new Cache();
$configFileManager->setupCache($configCache);
$configCache->delete('system', 'default_timezone');
$configFileManager->saveData($configCache);
// assert that system.default_timezone is now the restored 'UTC' from the defaults
$configCache = new Cache();
$configFileManager->setupCache($configCache);
self::assertEquals('UTC', $configCache->get('system', 'default_timezone'));
}
/**
* Test for empty node.config.php
*/