mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-11 12:04:26 +02:00
adapt tests
This commit is contained in:
parent
d272e8c3c7
commit
326566638f
16 changed files with 254 additions and 712 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Config\Cache;
|
||||
|
||||
use Friendica\Core\Config\Cache;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Test\MockedTest;
|
||||
use ParagonIE\HiddenString\HiddenString;
|
||||
use stdClass;
|
||||
|
@ -49,7 +49,7 @@ class CacheTest extends MockedTest
|
|||
];
|
||||
}
|
||||
|
||||
private function assertConfigValues($data, \Friendica\Core\Config\ValueObject\Cache $configCache)
|
||||
private function assertConfigValues($data, 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 \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache = new Cache();
|
||||
$configCache->load($data);
|
||||
|
||||
self::assertConfigValues($data, $configCache);
|
||||
|
@ -83,27 +83,27 @@ class CacheTest extends MockedTest
|
|||
]
|
||||
];
|
||||
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
$configCache = new Cache();
|
||||
$configCache->load($data, Cache::SOURCE_DATA);
|
||||
// doesn't override - Low Priority due Config file
|
||||
$configCache->load($override, \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
|
||||
$configCache->load($override, Cache::SOURCE_FILE);
|
||||
|
||||
self::assertConfigValues($data, $configCache);
|
||||
|
||||
// override the value - High Prio due Server Env
|
||||
$configCache->load($override, \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV);
|
||||
$configCache->load($override, 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, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
$configCache->load($data, Cache::SOURCE_DATA);
|
||||
|
||||
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, \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV);
|
||||
$configCache->load($data, 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 \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
// empty dataset
|
||||
$configCache->load([]);
|
||||
|
@ -136,7 +136,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetAll($data)
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache = new Cache();
|
||||
$configCache->load($data);
|
||||
|
||||
$all = $configCache->getAll();
|
||||
|
@ -151,7 +151,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testSetGet($data)
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
foreach ($data as $cat => $values) {
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -167,7 +167,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetEmpty()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
self::assertNull($configCache->get('something', 'value'));
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testGetCat()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new Cache([
|
||||
'system' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
|
@ -205,7 +205,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testDelete($data)
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
$configCache = new 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 \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
$configCache = new Cache($data);
|
||||
|
||||
$diffConfig = [
|
||||
'fakeCat' => [
|
||||
|
@ -239,7 +239,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testKeyDiffWithoutResult($data)
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache($data);
|
||||
$configCache = new Cache($data);
|
||||
|
||||
$diffConfig = $configCache->getAll();
|
||||
|
||||
|
@ -251,7 +251,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testPasswordHide()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new Cache([
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
|
@ -268,7 +268,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testPasswordShow()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new Cache([
|
||||
'database' => [
|
||||
'password' => 'supersecure',
|
||||
'username' => 'notsecured',
|
||||
|
@ -285,7 +285,7 @@ class CacheTest extends MockedTest
|
|||
*/
|
||||
public function testEmptyPassword()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new Cache([
|
||||
'database' => [
|
||||
'password' => '',
|
||||
'username' => '',
|
||||
|
@ -299,7 +299,7 @@ class CacheTest extends MockedTest
|
|||
|
||||
public function testWrongTypePassword()
|
||||
{
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new 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 \Friendica\Core\Config\ValueObject\Cache([
|
||||
$configCache = new Cache([
|
||||
'database' => [
|
||||
'password' => 23,
|
||||
'username' => '',
|
||||
|
@ -327,19 +327,35 @@ class CacheTest extends MockedTest
|
|||
public function testSetOverrides($data)
|
||||
{
|
||||
|
||||
$configCache = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configCache->load($data, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB);
|
||||
$configCache = new Cache();
|
||||
$configCache->load($data, Cache::SOURCE_DATA);
|
||||
|
||||
// test with wrong override
|
||||
self::assertFalse($configCache->set('system', 'test', '1234567', \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE));
|
||||
self::assertFalse($configCache->set('system', 'test', '1234567', Cache::SOURCE_FILE));
|
||||
self::assertEquals($data['system']['test'], $configCache->get('system', 'test'));
|
||||
|
||||
// test with override (equal)
|
||||
self::assertTrue($configCache->set('system', 'test', '8910', \Friendica\Core\Config\ValueObject\Cache::SOURCE_DB));
|
||||
self::assertTrue($configCache->set('system', 'test', '8910', Cache::SOURCE_DATA));
|
||||
self::assertEquals('8910', $configCache->get('system', 'test'));
|
||||
|
||||
// test with override (over)
|
||||
self::assertTrue($configCache->set('system', 'test', '111213', \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV));
|
||||
self::assertTrue($configCache->set('system', 'test', '111213', Cache::SOURCE_ENV));
|
||||
self::assertEquals('111213', $configCache->get('system', 'test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetData($data)
|
||||
{
|
||||
$configCache = new Cache();
|
||||
$configCache->load($data, Cache::SOURCE_FILE);
|
||||
|
||||
$configCache->set('system', 'test_2','with_data', Cache::SOURCE_DATA);
|
||||
|
||||
$this->assertEquals(['system' => ['test_2' => 'with_data']], $configCache->getDataBySource(Cache::SOURCE_DATA));
|
||||
$this->assertEquals($data, $configCache->getDataBySource(Cache::SOURCE_FILE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ use Friendica\Core\Config\Cache;
|
|||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Core\Config\Util\ConfigFileLoader;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class ConfigFileLoaderTest extends MockedTest
|
||||
|
@ -46,7 +46,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
{
|
||||
$this->delConfigFile('local.config.php');
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -72,7 +72,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent('<?php return true;');
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -101,7 +101,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -138,7 +138,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -174,7 +174,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root)
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -228,7 +228,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('addon')->getChild('test')->getChild('config'))
|
||||
->setContent(file_get_contents($file));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -265,7 +265,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.config.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -299,7 +299,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.ini.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -333,7 +333,7 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($fileDir . 'B.ini.php'));
|
||||
|
||||
$configFileLoader = new ConfigFileLoader(
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
|
@ -386,4 +386,45 @@ class ConfigFileLoaderTest 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'));
|
||||
|
||||
$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);
|
||||
|
||||
// overwrite some data and save it back to the config file
|
||||
$configCache->set('system', 'test', 'it', \Friendica\Core\Config\ValueObject\Cache::SOURCE_DATA);
|
||||
$configCache->set('config', 'test', 'it', \Friendica\Core\Config\ValueObject\Cache::SOURCE_DATA);
|
||||
$configCache->set('system', 'test_2', 2, \Friendica\Core\Config\ValueObject\Cache::SOURCE_DATA);
|
||||
$configFileLoader->saveData($configCache);
|
||||
|
||||
// Reload the configCache with the new values
|
||||
$configCache2 = new \Friendica\Core\Config\ValueObject\Cache();
|
||||
$configFileLoader->setupCache($configCache2);
|
||||
|
||||
self::assertEquals($configCache, $configCache2);
|
||||
self::assertEquals([
|
||||
'system' => [
|
||||
'test' => 'it',
|
||||
'test_2' => 2
|
||||
],
|
||||
'config' => [
|
||||
'test' => 'it'
|
||||
]], $configCache2->getDataBySource(\Friendica\Core\Config\ValueObject\Cache::SOURCE_DATA));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,22 +23,25 @@ namespace Friendica\Test\src\Core\Config;
|
|||
|
||||
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Config\Repository\Config as ConfigModel;
|
||||
use Friendica\Core\Config\Model\Config;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Core\Config\Util\ConfigFileTransformer;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Mockery\MockInterface;
|
||||
use Mockery;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
abstract class ConfigTest extends MockedTest
|
||||
class ConfigTest extends MockedTest
|
||||
{
|
||||
use ArraySubsetAsserts;
|
||||
|
||||
/** @var ConfigModel|MockInterface */
|
||||
protected $configModel;
|
||||
use VFSTrait;
|
||||
|
||||
/** @var Cache */
|
||||
protected $configCache;
|
||||
|
||||
/** @var ConfigFileManager */
|
||||
protected $configFileManager;
|
||||
|
||||
/** @var IManageConfigValues */
|
||||
protected $testedConfig;
|
||||
|
||||
|
@ -60,17 +63,22 @@ abstract class ConfigTest extends MockedTest
|
|||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUpVfsDir();
|
||||
|
||||
parent::setUp();
|
||||
|
||||
// Create the config model
|
||||
$this->configModel = Mockery::mock(ConfigModel::class);
|
||||
$this->configCache = new Cache();
|
||||
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IManageConfigValues
|
||||
*/
|
||||
abstract public function getInstance();
|
||||
public function getInstance()
|
||||
{
|
||||
$this->configFileManager->setupCache($this->configCache, []);
|
||||
return new Config($this->configFileManager, $this->configCache);
|
||||
}
|
||||
|
||||
public function dataTests()
|
||||
{
|
||||
|
@ -156,12 +164,13 @@ abstract class ConfigTest extends MockedTest
|
|||
|
||||
/**
|
||||
* Test the configuration initialization
|
||||
* @dataProvider dataConfigLoad
|
||||
*/
|
||||
public function testSetUp(array $data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(ConfigFileTransformer::encode($data));
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
@ -171,19 +180,23 @@ abstract class ConfigTest extends MockedTest
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the configuration load() method
|
||||
* Test the configuration reload() method
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*
|
||||
* @dataProvider dataConfigLoad
|
||||
*/
|
||||
public function testLoad(array $data, array $load)
|
||||
public function testReload(array $data, array $load)
|
||||
{
|
||||
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(ConfigFileTransformer::encode($data));
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
foreach ($load as $loadedCats) {
|
||||
$this->testedConfig->load($loadedCats);
|
||||
}
|
||||
$this->testedConfig->reload();
|
||||
|
||||
// Assert at least loaded cats are loaded
|
||||
foreach ($load as $loadedCats) {
|
||||
|
@ -256,23 +269,31 @@ abstract class ConfigTest extends MockedTest
|
|||
|
||||
/**
|
||||
* Test the configuration load() method with overwrite
|
||||
*
|
||||
* @dataProvider dataDoubleLoad
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(ConfigFileTransformer::encode($data1));
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
foreach ($data1 as $cat => $data) {
|
||||
$this->testedConfig->load($cat);
|
||||
}
|
||||
|
||||
// Assert at least loaded cats are loaded
|
||||
foreach ($data1 as $cat => $data) {
|
||||
self::assertConfig($cat, $data);
|
||||
}
|
||||
|
||||
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(ConfigFileTransformer::encode($data2));
|
||||
|
||||
$this->testedConfig->reload();
|
||||
|
||||
foreach ($data2 as $cat => $data) {
|
||||
$this->testedConfig->load($cat);
|
||||
self::assertConfig($cat, $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,44 +302,19 @@ abstract class ConfigTest extends MockedTest
|
|||
*/
|
||||
public function testLoadWrong()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')->andReturn(true)->once();
|
||||
$this->configModel->shouldReceive('load')->withAnyArgs()->andReturn([])->once();
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
$this->testedConfig = new Config($this->configFileManager, new Cache());
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
self::assertEmpty($this->testedConfig->getCache()->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration get() and set() methods without adapter
|
||||
* Test the configuration get() and set() methods
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGetWithoutDB($data)
|
||||
public function testSetGet($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(false)
|
||||
->times(3);
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
self::assertTrue($this->testedConfig->set('test', 'it', $data));
|
||||
|
||||
self::assertEquals($data, $this->testedConfig->get('test', 'it'));
|
||||
self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration get() and set() methods with a model/db
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGetWithDB($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('set')->with('test', 'it', $data)->andReturn(true)->once();
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
|
@ -349,41 +345,16 @@ abstract class ConfigTest extends MockedTest
|
|||
self::assertEquals('default', $this->testedConfig->get('test', 'it', 'default', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration get() method with refresh
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testGetWithRefresh($data)
|
||||
{
|
||||
$this->configCache->load(['test' => ['it' => 'now']], Cache::SOURCE_FILE);
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
// without refresh
|
||||
self::assertEquals('now', $this->testedConfig->get('test', 'it'));
|
||||
self::assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
|
||||
|
||||
// with refresh
|
||||
self::assertEquals($data, $this->testedConfig->get('test', 'it', null, true));
|
||||
self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
|
||||
|
||||
// without refresh and wrong value and default
|
||||
self::assertEquals('default', $this->testedConfig->get('test', 'not', 'default'));
|
||||
self::assertNull($this->testedConfig->getCache()->get('test', 'not'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration delete() method without a model/db
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testDeleteWithoutDB($data)
|
||||
public function testDelete($data)
|
||||
{
|
||||
$this->configCache->load(['test' => ['it' => $data]], Cache::SOURCE_FILE);
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
$this->testedConfig = new Config($this->configFileManager, $this->configCache);
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
self::assertEquals($data, $this->testedConfig->get('test', 'it'));
|
||||
|
@ -396,51 +367,6 @@ abstract class ConfigTest extends MockedTest
|
|||
self::assertEmpty($this->testedConfig->getCache()->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration delete() method with a model/db
|
||||
*/
|
||||
public function testDeleteWithDB()
|
||||
{
|
||||
$this->configCache->load(['test' => ['it' => 'now', 'quarter' => 'true']], Cache::SOURCE_FILE);
|
||||
|
||||
$this->configModel->shouldReceive('delete')
|
||||
->with('test', 'it')
|
||||
->andReturn(false)
|
||||
->once();
|
||||
$this->configModel->shouldReceive('delete')
|
||||
->with('test', 'second')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
$this->configModel->shouldReceive('delete')
|
||||
->with('test', 'third')
|
||||
->andReturn(false)
|
||||
->once();
|
||||
$this->configModel->shouldReceive('delete')
|
||||
->with('test', 'quarter')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
||||
// directly set the value to the cache
|
||||
$this->testedConfig->getCache()->set('test', 'it', 'now');
|
||||
|
||||
self::assertEquals('now', $this->testedConfig->get('test', 'it'));
|
||||
self::assertEquals('now', $this->testedConfig->getCache()->get('test', 'it'));
|
||||
|
||||
// delete from cache only
|
||||
self::assertTrue($this->testedConfig->delete('test', 'it'));
|
||||
// delete from db only
|
||||
self::assertTrue($this->testedConfig->delete('test', 'second'));
|
||||
// no delete
|
||||
self::assertFalse($this->testedConfig->delete('test', 'third'));
|
||||
// delete both
|
||||
self::assertTrue($this->testedConfig->delete('test', 'quarter'));
|
||||
|
||||
self::assertEmpty($this->testedConfig->getCache()->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the configuration get() and set() method where the db value has a higher prio than the config file
|
||||
*/
|
||||
|
@ -462,6 +388,12 @@ abstract class ConfigTest extends MockedTest
|
|||
*/
|
||||
public function testSetGetLowPrio()
|
||||
{
|
||||
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(ConfigFileTransformer::encode([
|
||||
'config' => ['test' => 'it'],
|
||||
]));
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
self::assertEquals('it', $this->testedConfig->get('config', 'test'));
|
||||
|
|
|
@ -1,255 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2023, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Test\src\Core\Config;
|
||||
|
||||
use Friendica\Core\Config\Type\JitConfig;
|
||||
|
||||
class JitConfigTest extends ConfigTest
|
||||
{
|
||||
public function getInstance()
|
||||
{
|
||||
return new JitConfig($this->configCache, $this->configModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*/
|
||||
public function testSetUp(array $data)
|
||||
{
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => $data['config']])
|
||||
->once();
|
||||
|
||||
parent::testSetUp($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*/
|
||||
public function testLoad(array $data, array $load)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(count($load) + 1);
|
||||
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => $data['config']])
|
||||
->once();
|
||||
|
||||
foreach ($load as $loadCat) {
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with($loadCat)
|
||||
->andReturn([$loadCat => $data[$loadCat]])
|
||||
->once();
|
||||
}
|
||||
|
||||
parent::testLoad($data, $load);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataDoubleLoad
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(count($data1) + count($data2) + 1);
|
||||
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => $data1['config']])
|
||||
->once();
|
||||
|
||||
foreach ($data1 as $cat => $data) {
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with($cat)
|
||||
->andReturn([$cat => $data])
|
||||
->once();
|
||||
}
|
||||
|
||||
|
||||
foreach ($data2 as $cat => $data) {
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with($cat)
|
||||
->andReturn([$cat => $data])
|
||||
->once();
|
||||
}
|
||||
|
||||
parent::testCacheLoadDouble($data1, $data2);
|
||||
|
||||
// Assert the expected categories
|
||||
foreach ($data2 as $cat => $data) {
|
||||
self::assertConfig($cat, $expect[$cat]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGetWithDB($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(3);
|
||||
|
||||
$this->configModel->shouldReceive('load')->with('config')->andReturn(['config' => []])->once();
|
||||
|
||||
parent::testSetGetWithDB($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testGetWithRefresh($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(4);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
// mocking one get without result
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
->andReturn(null)
|
||||
->once();
|
||||
|
||||
// mocking the data get
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
->andReturn($data)
|
||||
->once();
|
||||
|
||||
// mocking second get
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('test', 'not')
|
||||
->andReturn(null)
|
||||
->once();
|
||||
|
||||
parent::testGetWithRefresh($data);
|
||||
}
|
||||
|
||||
public function testGetWrongWithoutDB()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(false)
|
||||
->times(4);
|
||||
|
||||
parent::testGetWrongWithoutDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testDeleteWithoutDB($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(false)
|
||||
->times(4);
|
||||
|
||||
parent::testDeleteWithoutDB($data);
|
||||
}
|
||||
|
||||
public function testDeleteWithDB()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(6);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
// mocking one get without result
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
->andReturn(null)
|
||||
->once();
|
||||
|
||||
parent::testDeleteWithDB();
|
||||
}
|
||||
|
||||
public function testSetGetHighPrio()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('config', 'test')
|
||||
->andReturn('prio')
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('set')
|
||||
->with('config', 'test', '123')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('config', 'test')
|
||||
->andReturn('123')
|
||||
->once();
|
||||
|
||||
parent::testSetGetHighPrio();
|
||||
}
|
||||
|
||||
public function testSetGetLowPrio()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->with('config')
|
||||
->andReturn(['config' => ['test' => 'it']])
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('set')
|
||||
->with('config', 'test', '123')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
// mocking one get without result
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('config', 'test')
|
||||
->andReturn('it')
|
||||
->once();
|
||||
|
||||
parent::testSetGetLowPrio();
|
||||
}
|
||||
}
|
|
@ -1,213 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2023, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Test\src\Core\Config;
|
||||
|
||||
use Friendica\Core\Config\Type\PreloadConfig;
|
||||
|
||||
class PreloadConfigTest extends ConfigTest
|
||||
{
|
||||
public function getInstance()
|
||||
{
|
||||
return new PreloadConfig($this->configCache, $this->configModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*/
|
||||
public function testSetUp(array $data)
|
||||
{
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn($data)
|
||||
->once();
|
||||
|
||||
parent::testSetUp($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*/
|
||||
public function testLoad(array $data, array $load)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn($data)
|
||||
->once();
|
||||
|
||||
parent::testLoad($data, $load);
|
||||
|
||||
// Assert that every category is loaded everytime
|
||||
foreach ($data as $cat => $values) {
|
||||
self::assertConfig($cat, $values);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataDoubleLoad
|
||||
*
|
||||
* @param array $data1
|
||||
* @param array $data2
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn($data1)
|
||||
->once();
|
||||
|
||||
parent::testCacheLoadDouble($data1, $data2);
|
||||
|
||||
// Assert that every category is loaded everytime and is NOT overwritten
|
||||
foreach ($data1 as $cat => $values) {
|
||||
self::assertConfig($cat, $values);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testSetGetWithDB($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(2);
|
||||
|
||||
$this->configModel->shouldReceive('load')->andReturn(['config' => []])->once();
|
||||
|
||||
parent::testSetGetWithDB($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testGetWithRefresh($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(2);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
// mocking one get
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
->andReturn($data)
|
||||
->once();
|
||||
|
||||
parent::testGetWithRefresh($data);
|
||||
}
|
||||
|
||||
|
||||
public function testGetWrongWithoutDB()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(false)
|
||||
->times(2);
|
||||
|
||||
parent::testGetWrongWithoutDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testDeleteWithoutDB($data)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(false)
|
||||
->times(2);
|
||||
|
||||
parent::testDeleteWithoutDB($data);
|
||||
}
|
||||
|
||||
public function testDeleteWithDB()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
->times(5);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
parent::testDeleteWithDB();
|
||||
}
|
||||
|
||||
|
||||
public function testSetGetHighPrio()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn(['config' => []])
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('set')
|
||||
->with('config', 'test', '123')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('config', 'test')
|
||||
->andReturn('123')
|
||||
->once();
|
||||
|
||||
parent::testSetGetHighPrio();
|
||||
}
|
||||
|
||||
public function testSetGetLowPrio()
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true);
|
||||
|
||||
// constructor loading
|
||||
$this->configModel->shouldReceive('load')
|
||||
->andReturn(['config' => ['test' => 'it']])
|
||||
->once();
|
||||
|
||||
$this->configModel->shouldReceive('set')
|
||||
->with('config', 'test', '123')
|
||||
->andReturn(true)
|
||||
->once();
|
||||
|
||||
// mocking one get without result
|
||||
$this->configModel->shouldReceive('get')
|
||||
->with('config', 'test')
|
||||
->andReturn('it')
|
||||
->once();
|
||||
|
||||
parent::testSetGetLowPrio();
|
||||
}
|
||||
}
|
|
@ -24,7 +24,10 @@ namespace Friendica\Test\src\Core\Lock;
|
|||
use Dice\Dice;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Config\Model\Config;
|
||||
use Friendica\Core\Config\Type\JitConfig;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Core\Lock\Type\SemaphoreLock;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
@ -42,11 +45,8 @@ class SemaphoreLockTest extends LockTest
|
|||
$app->shouldReceive('getHostname')->andReturn('friendica.local');
|
||||
$dice->shouldReceive('create')->with(App::class)->andReturn($app);
|
||||
|
||||
$configMock = Mockery::mock(JitConfig::class);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'temppath')
|
||||
->andReturn('/tmp/');
|
||||
$configCache = new Cache(['system' => ['temppath' => '/tmp']]);
|
||||
$configMock = new Config(Mockery::mock(ConfigFileManager::class), $configCache);
|
||||
$dice->shouldReceive('create')->with(IManageConfigValues::class)->andReturn($configMock);
|
||||
|
||||
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
namespace Friendica\Test\src\Core\Storage\Repository;
|
||||
|
||||
use Dice\Dice;
|
||||
use Friendica\App\Mode;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Config\Type\PreloadConfig;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
|
@ -41,7 +39,6 @@ use Friendica\Database\Definition\DbaDefinition;
|
|||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Core\Config\Repository;
|
||||
use Friendica\Core\Storage\Type;
|
||||
use Friendica\Test\DatabaseTest;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
|
@ -89,8 +86,7 @@ class StorageManagerTest extends DatabaseTest
|
|||
|
||||
$this->dba = new StaticDatabase($configCache, $profiler, $dbaDefinition, $viewDefinition);
|
||||
|
||||
$configModel = new Repository\Config($this->dba, new Mode(Mode::DBCONFIGAVAILABLE));
|
||||
$this->config = new PreloadConfig($configCache, $configModel);
|
||||
$this->config = new \Friendica\Core\Config\Model\Config($loader, $configCache);
|
||||
$this->config->set('storage', 'name', 'Database');
|
||||
$this->config->set('storage', 'filesystem_path', $this->root->getChild(Type\FilesystemConfig::DEFAULT_BASE_FOLDER)->url());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue