2019-02-10 18:52:21 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2023-01-01 14:36:24 +00:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2020-02-09 14:45:36 +00:00
|
|
|
*
|
|
|
|
* @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/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2019-02-27 11:32:56 +00:00
|
|
|
namespace Friendica\Test\src\Core\Config;
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2021-12-10 20:34:19 +00:00
|
|
|
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
2021-10-26 19:44:29 +00:00
|
|
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
2023-01-01 20:10:41 +00:00
|
|
|
use Friendica\Core\Config\Model\Config;
|
|
|
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
|
|
|
use Friendica\Core\Config\Util\ConfigFileTransformer;
|
2021-12-10 20:34:19 +00:00
|
|
|
use Friendica\Core\Config\ValueObject\Cache;
|
2019-02-10 18:52:21 +00:00
|
|
|
use Friendica\Test\MockedTest;
|
2023-01-01 20:10:41 +00:00
|
|
|
use Friendica\Test\Util\VFSTrait;
|
|
|
|
use org\bovigo\vfs\vfsStream;
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2023-01-01 20:10:41 +00:00
|
|
|
class ConfigTest extends MockedTest
|
2019-02-10 18:52:21 +00:00
|
|
|
{
|
2021-12-10 20:34:19 +00:00
|
|
|
use ArraySubsetAsserts;
|
2023-01-01 20:10:41 +00:00
|
|
|
use VFSTrait;
|
2019-07-02 22:42:47 +00:00
|
|
|
|
2021-12-10 20:34:19 +00:00
|
|
|
/** @var Cache */
|
2019-07-02 22:42:47 +00:00
|
|
|
protected $configCache;
|
|
|
|
|
2023-01-01 20:10:41 +00:00
|
|
|
/** @var ConfigFileManager */
|
|
|
|
protected $configFileManager;
|
|
|
|
|
2021-10-26 20:09:11 +00:00
|
|
|
/** @var IManageConfigValues */
|
2019-07-02 22:42:47 +00:00
|
|
|
protected $testedConfig;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert a config tree
|
|
|
|
*
|
|
|
|
* @param string $cat The category to assert
|
|
|
|
* @param array $data The result data array
|
|
|
|
*/
|
|
|
|
protected function assertConfig(string $cat, array $data)
|
|
|
|
{
|
|
|
|
$result = $this->testedConfig->getCache()->getAll();
|
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertNotEmpty($result);
|
|
|
|
self::assertArrayHasKey($cat, $result);
|
|
|
|
self::assertArraySubset($data, $result[$cat]);
|
2019-07-02 22:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-01 21:04:30 +00:00
|
|
|
protected function setUp(): void
|
2019-07-02 22:42:47 +00:00
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
$this->setUpVfsDir();
|
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
parent::setUp();
|
|
|
|
|
2021-12-10 20:34:19 +00:00
|
|
|
$this->configCache = new Cache();
|
2023-01-01 20:10:41 +00:00
|
|
|
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
2019-07-02 22:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-26 20:09:11 +00:00
|
|
|
* @return IManageConfigValues
|
2019-07-02 22:42:47 +00:00
|
|
|
*/
|
2023-01-01 20:10:41 +00:00
|
|
|
public function getInstance()
|
|
|
|
{
|
2023-01-05 21:13:10 +00:00
|
|
|
$this->configFileManager->setupCache($this->configCache);
|
2023-01-01 20:10:41 +00:00
|
|
|
return new Config($this->configFileManager, $this->configCache);
|
|
|
|
}
|
2019-07-02 22:42:47 +00:00
|
|
|
|
2019-02-11 20:36:26 +00:00
|
|
|
public function dataTests()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'string' => ['data' => 'it'],
|
|
|
|
'boolTrue' => ['data' => true],
|
|
|
|
'boolFalse' => ['data' => false],
|
|
|
|
'integer' => ['data' => 235],
|
|
|
|
'decimal' => ['data' => 2.456],
|
|
|
|
'array' => ['data' => ['1', 2, '3', true, false]],
|
|
|
|
'boolIntTrue' => ['data' => 1],
|
|
|
|
'boolIntFalse' => ['Data' => 0],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
public function dataConfigLoad()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'system' => [
|
|
|
|
'key1' => 'value1',
|
|
|
|
'key2' => 'value2',
|
|
|
|
'key3' => 'value3',
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'key1' => 'value1a',
|
|
|
|
'key4' => 'value4',
|
|
|
|
],
|
|
|
|
'other' => [
|
|
|
|
'key5' => 'value5',
|
|
|
|
'key6' => 'value6',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
return [
|
|
|
|
'system' => [
|
|
|
|
'data' => $data,
|
|
|
|
'possibleCats' => [
|
|
|
|
'system',
|
|
|
|
'config',
|
|
|
|
'other'
|
|
|
|
],
|
|
|
|
'load' => [
|
|
|
|
'system',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'other' => [
|
|
|
|
'data' => $data,
|
|
|
|
'possibleCats' => [
|
|
|
|
'system',
|
|
|
|
'config',
|
|
|
|
'other'
|
|
|
|
],
|
|
|
|
'load' => [
|
|
|
|
'other',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'data' => $data,
|
|
|
|
'possibleCats' => [
|
|
|
|
'system',
|
|
|
|
'config',
|
|
|
|
'other'
|
|
|
|
],
|
|
|
|
'load' => [
|
|
|
|
'config',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'all' => [
|
|
|
|
'data' => $data,
|
|
|
|
'possibleCats' => [
|
|
|
|
'system',
|
|
|
|
'config',
|
|
|
|
'other'
|
|
|
|
],
|
|
|
|
'load' => [
|
|
|
|
'system',
|
|
|
|
'config',
|
|
|
|
'other'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2019-02-10 18:52:21 +00:00
|
|
|
/**
|
|
|
|
* Test the configuration initialization
|
2023-01-01 20:10:41 +00:00
|
|
|
* @dataProvider dataConfigLoad
|
2019-02-10 18:52:21 +00:00
|
|
|
*/
|
2019-07-02 22:42:47 +00:00
|
|
|
public function testSetUp(array $data)
|
2019-02-10 18:52:21 +00:00
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
|
|
|
->at($this->root->getChild('config'))
|
|
|
|
->setContent(ConfigFileTransformer::encode($data));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
// assert config is loaded everytime
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertConfig('config', $data['config']);
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-01-01 20:10:41 +00:00
|
|
|
* Test the configuration reload() method
|
2020-10-18 18:31:57 +00:00
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @param array $load
|
2023-01-01 20:10:41 +00:00
|
|
|
*
|
|
|
|
* @dataProvider dataConfigLoad
|
2019-02-10 18:52:21 +00:00
|
|
|
*/
|
2023-01-01 20:10:41 +00:00
|
|
|
public function testReload(array $data, array $load)
|
2019-02-10 18:52:21 +00:00
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
|
|
|
->at($this->root->getChild('config'))
|
|
|
|
->setContent(ConfigFileTransformer::encode($data));
|
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-07-02 22:42:47 +00:00
|
|
|
|
2023-01-01 20:10:41 +00:00
|
|
|
$this->testedConfig->reload();
|
2019-07-02 22:42:47 +00:00
|
|
|
|
|
|
|
// Assert at least loaded cats are loaded
|
|
|
|
foreach ($load as $loadedCats) {
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertConfig($loadedCats, $data[$loadedCats]);
|
2019-07-02 22:42:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function dataDoubleLoad()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'config' => [
|
|
|
|
'data1' => [
|
|
|
|
'config' => [
|
|
|
|
'key1' => 'value1',
|
|
|
|
'key2' => 'value2',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'data2' => [
|
|
|
|
'config' => [
|
|
|
|
'key1' => 'overwritten!',
|
|
|
|
'key3' => 'value3',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'expect' => [
|
|
|
|
'config' => [
|
|
|
|
// load should overwrite values everytime!
|
|
|
|
'key1' => 'overwritten!',
|
|
|
|
'key2' => 'value2',
|
|
|
|
'key3' => 'value3',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'other' => [
|
|
|
|
'data1' => [
|
|
|
|
'config' => [
|
|
|
|
'key12' => 'data4',
|
|
|
|
'key45' => 7,
|
|
|
|
],
|
|
|
|
'other' => [
|
|
|
|
'key1' => 'value1',
|
|
|
|
'key2' => 'value2',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'data2' => [
|
|
|
|
'other' => [
|
|
|
|
'key1' => 'overwritten!',
|
|
|
|
'key3' => 'value3',
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'key45' => 45,
|
|
|
|
'key52' => true,
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'expect' => [
|
|
|
|
'other' => [
|
|
|
|
// load should overwrite values everytime!
|
|
|
|
'key1' => 'overwritten!',
|
|
|
|
'key2' => 'value2',
|
|
|
|
'key3' => 'value3',
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'key12' => 'data4',
|
|
|
|
'key45' => 45,
|
|
|
|
'key52' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-11 20:36:26 +00:00
|
|
|
* Test the configuration load() method with overwrite
|
2023-01-01 20:10:41 +00:00
|
|
|
*
|
|
|
|
* @dataProvider dataDoubleLoad
|
2019-02-10 18:52:21 +00:00
|
|
|
*/
|
2020-10-18 18:31:57 +00:00
|
|
|
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
2019-02-10 18:52:21 +00:00
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
|
|
|
->at($this->root->getChild('config'))
|
|
|
|
->setContent(ConfigFileTransformer::encode($data1));
|
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-07-02 22:42:47 +00:00
|
|
|
|
|
|
|
// Assert at least loaded cats are loaded
|
|
|
|
foreach ($data1 as $cat => $data) {
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertConfig($cat, $data);
|
2019-07-02 22:42:47 +00:00
|
|
|
}
|
|
|
|
|
2023-01-01 20:10:41 +00:00
|
|
|
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
|
|
|
->at($this->root->getChild('config'))
|
|
|
|
->setContent(ConfigFileTransformer::encode($data2));
|
|
|
|
|
|
|
|
$this->testedConfig->reload();
|
|
|
|
|
2019-07-02 22:42:47 +00:00
|
|
|
foreach ($data2 as $cat => $data) {
|
2023-01-01 20:10:41 +00:00
|
|
|
self::assertConfig($cat, $data);
|
2019-07-02 22:42:47 +00:00
|
|
|
}
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2019-07-04 19:39:49 +00:00
|
|
|
/**
|
|
|
|
* Test the configuration load without result
|
|
|
|
*/
|
|
|
|
public function testLoadWrong()
|
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
$this->testedConfig = new Config($this->configFileManager, new Cache());
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-07-04 19:39:49 +00:00
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEmpty($this->testedConfig->getCache()->getAll());
|
2019-07-04 19:39:49 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 18:52:21 +00:00
|
|
|
/**
|
2023-01-01 20:10:41 +00:00
|
|
|
* Test the configuration get() and set() methods
|
2019-07-02 22:42:47 +00:00
|
|
|
*
|
2019-02-11 20:36:26 +00:00
|
|
|
* @dataProvider dataTests
|
2019-02-10 18:52:21 +00:00
|
|
|
*/
|
2023-01-01 20:10:41 +00:00
|
|
|
public function testSetGet($data)
|
2019-02-10 18:52:21 +00:00
|
|
|
{
|
2019-07-02 22:42:47 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertTrue($this->testedConfig->set('test', 'it', $data));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEquals($data, $this->testedConfig->get('test', 'it'));
|
|
|
|
self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the configuration get() method with wrong value and no db
|
|
|
|
*/
|
|
|
|
public function testGetWrongWithoutDB()
|
|
|
|
{
|
2019-07-02 22:42:47 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
// without refresh
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertNull($this->testedConfig->get('test', 'it'));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
/// beware that the cache returns '!<unset>!' and not null for a non existing value
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertNull($this->testedConfig->getCache()->get('test', 'it'));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
// with default value
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEquals('default', $this->testedConfig->get('test', 'it', 'default'));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
|
|
|
// with default value and refresh
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEquals('default', $this->testedConfig->get('test', 'it', 'default', true));
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-11 20:36:26 +00:00
|
|
|
/**
|
2019-07-02 22:42:47 +00:00
|
|
|
* Test the configuration delete() method without a model/db
|
|
|
|
*
|
2019-02-11 20:36:26 +00:00
|
|
|
* @dataProvider dataTests
|
|
|
|
*/
|
2023-01-01 20:10:41 +00:00
|
|
|
public function testDelete($data)
|
2019-02-11 20:36:26 +00:00
|
|
|
{
|
2021-12-10 20:34:19 +00:00
|
|
|
$this->configCache->load(['test' => ['it' => $data]], Cache::SOURCE_FILE);
|
2019-02-11 20:36:26 +00:00
|
|
|
|
2023-01-01 20:10:41 +00:00
|
|
|
$this->testedConfig = new Config($this->configFileManager, $this->configCache);
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2019-02-11 20:36:26 +00:00
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEquals($data, $this->testedConfig->get('test', 'it'));
|
|
|
|
self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
|
2019-02-11 20:36:26 +00:00
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertTrue($this->testedConfig->delete('test', 'it'));
|
|
|
|
self::assertNull($this->testedConfig->get('test', 'it'));
|
|
|
|
self::assertNull($this->testedConfig->getCache()->get('test', 'it'));
|
2019-02-10 18:52:21 +00:00
|
|
|
|
2023-01-06 00:02:47 +00:00
|
|
|
self::assertEquals(['test' => null], $this->testedConfig->getCache()->getAll());
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2021-03-28 21:25:16 +00:00
|
|
|
/**
|
|
|
|
* Test the configuration get() and set() method where the db value has a higher prio than the config file
|
|
|
|
*/
|
|
|
|
public function testSetGetHighPrio()
|
|
|
|
{
|
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2021-03-28 21:25:16 +00:00
|
|
|
|
2021-12-10 20:34:19 +00:00
|
|
|
$this->testedConfig->getCache()->set('config', 'test', 'prio', Cache::SOURCE_FILE);
|
2021-03-28 21:25:16 +00:00
|
|
|
self::assertEquals('prio', $this->testedConfig->get('config', 'test'));
|
|
|
|
|
|
|
|
// now you have to get the new variable entry because of the new set the get refresh succeed as well
|
|
|
|
self::assertTrue($this->testedConfig->set('config', 'test', '123'));
|
|
|
|
self::assertEquals('123', $this->testedConfig->get('config', 'test', '', true));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the configuration get() and set() method where the db value has a lower prio than the env
|
|
|
|
*/
|
|
|
|
public function testSetGetLowPrio()
|
|
|
|
{
|
2023-01-01 20:10:41 +00:00
|
|
|
vfsStream::newFile(ConfigFileManager::CONFIG_DATA_FILE)
|
|
|
|
->at($this->root->getChild('config'))
|
|
|
|
->setContent(ConfigFileTransformer::encode([
|
|
|
|
'config' => ['test' => 'it'],
|
|
|
|
]));
|
|
|
|
|
2021-03-28 21:25:16 +00:00
|
|
|
$this->testedConfig = $this->getInstance();
|
2021-12-10 20:34:19 +00:00
|
|
|
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
2021-03-28 21:25:16 +00:00
|
|
|
self::assertEquals('it', $this->testedConfig->get('config', 'test'));
|
|
|
|
|
2021-12-10 20:34:19 +00:00
|
|
|
$this->testedConfig->getCache()->set('config', 'test', 'prio', Cache::SOURCE_ENV);
|
2021-03-28 21:25:16 +00:00
|
|
|
// now you have to get the env variable entry as output, even with a new set (which failed) and a get refresh
|
|
|
|
self::assertFalse($this->testedConfig->set('config', 'test', '123'));
|
|
|
|
self::assertEquals('prio', $this->testedConfig->get('config', 'test', '', true));
|
|
|
|
}
|
2023-01-03 19:24:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
public function dataTestCat()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'test_with_hashmap' => [
|
|
|
|
'data' => [
|
|
|
|
'test_with_hashmap' => [
|
|
|
|
'notifyall' => [
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
'blockbot' => [
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'register_policy' => 2,
|
|
|
|
'register_text' => '',
|
|
|
|
'sitename' => 'Friendica Social Network23',
|
|
|
|
'hostname' => 'friendica.local',
|
|
|
|
'private_addons' => false,
|
|
|
|
],
|
|
|
|
'system' => [
|
|
|
|
'dbclean_expire_conversation' => 90,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'cat' => 'test_with_hashmap',
|
|
|
|
'assertion' => [
|
|
|
|
'notifyall' => [
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
'blockbot' => [
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'test_with_keys' => [
|
|
|
|
'data' => [
|
|
|
|
'test_with_keys' => [
|
|
|
|
[
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'register_policy' => 2,
|
|
|
|
'register_text' => '',
|
|
|
|
'sitename' => 'Friendica Social Network23',
|
|
|
|
'hostname' => 'friendica.local',
|
|
|
|
'private_addons' => false,
|
|
|
|
],
|
|
|
|
'system' => [
|
|
|
|
'dbclean_expire_conversation' => 90,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'cat' => 'test_with_keys',
|
|
|
|
'assertion' => [
|
|
|
|
[
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'test_with_inner_array' => [
|
|
|
|
'data' => [
|
|
|
|
'test_with_inner_array' => [
|
|
|
|
'notifyall' => [
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => [
|
|
|
|
'yes' => true,
|
|
|
|
'no' => 1.5,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'blogbot' => [
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'config' => [
|
|
|
|
'register_policy' => 2,
|
|
|
|
'register_text' => '',
|
|
|
|
'sitename' => 'Friendica Social Network23',
|
|
|
|
'hostname' => 'friendica.local',
|
|
|
|
'private_addons' => false,
|
|
|
|
],
|
|
|
|
'system' => [
|
|
|
|
'dbclean_expire_conversation' => 90,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'cat' => 'test_with_inner_array',
|
|
|
|
'assertion' => [
|
|
|
|
'notifyall' => [
|
|
|
|
'last_update' => 1671051565,
|
|
|
|
'admin' => [
|
|
|
|
'yes' => true,
|
|
|
|
'no' => 1.5,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'blogbot' => [
|
|
|
|
'last_update' => 1658952852,
|
|
|
|
'admin' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataTestCat
|
|
|
|
*/
|
|
|
|
public function testGetCategory(array $data, string $category, array $assertion)
|
|
|
|
{
|
|
|
|
$this->configCache = new Cache($data);
|
|
|
|
$config = new Config($this->configFileManager, $this->configCache);
|
|
|
|
|
|
|
|
self::assertEquals($assertion, $config->get($category));
|
|
|
|
}
|
2019-02-10 18:52:21 +00:00
|
|
|
}
|