1
0
Fork 0

Refactoring Core class structures ...

This commit is contained in:
Philipp Holzer 2021-10-26 21:44:29 +02:00
commit b216317477
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
130 changed files with 1625 additions and 1397 deletions

View file

@ -24,7 +24,7 @@ namespace Friendica\Test\src\App;
use Detection\MobileDetect;
use Friendica\App\Mode;
use Friendica\App\Module;
use Friendica\Core\Config\Cache\Cache;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Database\Database;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;

View file

@ -22,10 +22,10 @@
namespace Friendica\Test\src\App;
use Friendica\App;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\LegacyModule;
use Friendica\Module\HTTPException\PageNotFound;
use Friendica\Module\WellKnown\HostMeta;
@ -172,18 +172,18 @@ class ModuleTest extends DatabaseTest
*/
public function testModuleClass($assert, string $name, string $command, bool $privAdd)
{
$config = Mockery::mock(IConfig::class);
$config = Mockery::mock(IManageConfigValues::class);
$config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once();
$l10n = Mockery::mock(L10n::class);
$l10n->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
$cache = Mockery::mock(ICache::class);
$cache = Mockery::mock(ICanCache::class);
$cache->shouldReceive('get')->with('routerDispatchData')->andReturn('')->atMost()->once();
$cache->shouldReceive('get')->with('lastRoutesFileModifiedTime')->andReturn('')->atMost()->once();
$cache->shouldReceive('set')->withAnyArgs()->andReturn(false)->atMost()->twice();
$lock = Mockery::mock(ILock::class);
$lock = Mockery::mock(ICanLock::class);
$lock->shouldReceive('acquire')->andReturn(true);
$lock->shouldReceive('isLocked')->andReturn(false);

View file

@ -22,9 +22,9 @@
namespace Friendica\Test\src\App;
use Friendica\App\Router;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\L10n;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\Module;
use Friendica\Network\HTTPException\MethodNotAllowedException;
use Friendica\Network\HTTPException\NotFoundException;
@ -37,11 +37,11 @@ class RouterTest extends TestCase
/** @var L10n|MockInterface */
private $l10n;
/**
* @var ICache
* @var ICanCache
*/
private $cache;
/**
* @var ILock
* @var \Friendica\Core\Lock\Capability\ICanLock
*/
private $lock;
@ -52,11 +52,11 @@ class RouterTest extends TestCase
$this->l10n = Mockery::mock(L10n::class);
$this->l10n->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
$this->cache = Mockery::mock(ICache::class);
$this->cache = Mockery::mock(ICanCache::class);
$this->cache->shouldReceive('get')->andReturn(null);
$this->cache->shouldReceive('set')->andReturn(false);
$this->lock = Mockery::mock(ILock::class);
$this->lock = Mockery::mock(ICanLock::class);
$this->lock->shouldReceive('acquire')->andReturn(true);
$this->lock->shouldReceive('isLocked')->andReturn(false);
}

View file

@ -24,7 +24,7 @@ namespace Friendica\Test\src\Console;
use Dice\Dice;
use Friendica\App;
use Friendica\Console\AutomaticInstallation;
use Friendica\Core\Config\Cache\Cache;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Installer;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
@ -53,7 +53,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
private $assertFileDb;
/**
* @var \Friendica\Core\Config\Cache\Cache The configuration cache to check after each test
* @var \Friendica\Core\Config\ValueObject\Cache The configuration cache to check after each test
*/
private $configCache;

View file

@ -24,7 +24,7 @@ namespace Friendica\Test\src\Console;
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Console\Config;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
use Mockery\LegacyMockInterface;
use Mockery\MockInterface;
@ -35,7 +35,7 @@ class ConfigConsoleTest extends ConsoleTest
* @var App\Mode|MockInterface $appMode
*/
private $appMode;
/** @var IConfig|LegacyMockInterface|MockInterface */
/** @var IManageConfigValues|LegacyMockInterface|MockInterface */
private $configMock;
protected function setUp() : void
@ -52,7 +52,7 @@ class ConfigConsoleTest extends ConsoleTest
$this->appMode->shouldReceive('has')
->andReturn(true);
$this->configMock = Mockery::mock(IConfig::class);
$this->configMock = Mockery::mock(IManageConfigValues::class);
}
public function testSetGetKeyValue()

View file

@ -24,7 +24,7 @@ namespace Friendica\Test\src\Console;
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Console\Lock;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Lock\Capability\ICanLock;
use Mockery;
use Mockery\MockInterface;
@ -36,7 +36,7 @@ class LockConsoleTest extends ConsoleTest
private $appMode;
/**
* @var ILock|MockInterface
* @var ICanLock|MockInterface
*/
private $lockMock;
@ -54,7 +54,7 @@ class LockConsoleTest extends ConsoleTest
$this->appMode->shouldReceive('has')
->andReturn(true);
$this->lockMock = Mockery::mock(ILock::class);
$this->lockMock = Mockery::mock(ICanLock::class);
}
public function testList()

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Console;
use Friendica\Console\ServerBlock;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
class ServerBlockConsoleTest extends ConsoleTest
@ -38,7 +38,7 @@ class ServerBlockConsoleTest extends ConsoleTest
]
];
/**
* @var IConfig|Mockery\LegacyMockInterface|Mockery\MockInterface
* @var IManageConfigValues|Mockery\LegacyMockInterface|Mockery\MockInterface
*/
private $configMock;
@ -46,7 +46,7 @@ class ServerBlockConsoleTest extends ConsoleTest
{
parent::setUp();
$this->configMock = Mockery::mock(IConfig::class);
$this->configMock = Mockery::mock(IManageConfigValues::class);
}
/**

View file

@ -21,8 +21,8 @@
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Cache\Capability\ICanCacheInMemory;
use Friendica\Test\MockedTest;
use Friendica\Util\PidFile;
@ -34,12 +34,12 @@ abstract class CacheTest extends MockedTest
protected $startTime = 1417011228;
/**
* @var ICache
* @var ICanCache
*/
protected $instance;
/**
* @var IMemoryCache
* @var \Friendica\Core\Cache\Capability\ICanCacheInMemory
*/
protected $cache;

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache;
use Friendica\Core\Config\Factory\ConfigFactory;
use Friendica\Core\Config\Factory\Config;
use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait;
@ -53,8 +53,8 @@ class DatabaseCacheTest extends CacheTest
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
// load real config to avoid mocking every config-entry which is related to the Database class
$configFactory = new ConfigFactory();
$loader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), []);
$configFactory = new Config();
$loader = (new Config())->createConfigFileLoader($this->root->url(), []);
$configCache = $configFactory->createCache($loader);
$dba = new StaticDatabase($configCache, $profiler, $logger);

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\Type\MemcacheCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
/**
@ -34,7 +34,7 @@ class MemcacheCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHE_PORT'] ?? '11211';

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\Type\MemcachedCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
use Psr\Log\NullLogger;
@ -35,7 +35,7 @@ class MemcachedCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHED_PORT'] ?? '11211';

View file

@ -22,12 +22,12 @@
namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Cache\Capability\ICanCacheInMemory;
abstract class MemoryCacheTest extends CacheTest
{
/**
* @var IMemoryCache
* @var \Friendica\Core\Cache\Capability\ICanCacheInMemory
*/
protected $instance;
@ -35,7 +35,7 @@ abstract class MemoryCacheTest extends CacheTest
{
parent::setUp();
if (!($this->instance instanceof IMemoryCache)) {
if (!($this->instance instanceof ICanCacheInMemory)) {
throw new Exception('MemoryCacheTest unsupported');
}
}

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\Type\RedisCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Mockery;
/**
@ -34,7 +34,7 @@ class RedisCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
$port = $_SERVER['REDIS_PORT'] ?? 6379;

View file

@ -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'));
}
}

View file

@ -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);

View file

@ -22,8 +22,8 @@
namespace Friendica\Test\src\Core\Config;
use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Model\Config as ConfigModel;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Config\Repository\Config as ConfigModel;
use Friendica\Test\MockedTest;
use Mockery\MockInterface;
use Mockery;
@ -33,10 +33,10 @@ abstract class ConfigTest extends MockedTest
/** @var ConfigModel|MockInterface */
protected $configModel;
/** @var Cache\Cache */
/** @var \Friendica\Core\Config\ValueObject\Cache */
protected $configCache;
/** @var IConfig */
/** @var \Friendica\Core\Config\Capability\IManageConfigValues */
protected $testedConfig;
/**
@ -61,11 +61,11 @@ abstract class ConfigTest extends MockedTest
// Create the config model
$this->configModel = Mockery::mock(ConfigModel::class);
$this->configCache = new Cache\Cache();
$this->configCache = new \Friendica\Core\Config\ValueObject\Cache();
}
/**
* @return IConfig
* @return \Friendica\Core\Config\Capability\IManageConfigValues
*/
abstract public function getInstance();
@ -161,7 +161,7 @@ abstract class ConfigTest extends MockedTest
->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
// assert config is loaded everytime
self::assertConfig('config', $data['config']);
@ -176,7 +176,7 @@ abstract class ConfigTest extends MockedTest
public function testLoad(array $data, array $load)
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($loadedCats);
@ -257,7 +257,7 @@ abstract class ConfigTest extends MockedTest
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($cat);
@ -282,7 +282,7 @@ abstract class ConfigTest extends MockedTest
$this->configModel->shouldReceive('load')->withAnyArgs()->andReturn([])->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertEmpty($this->testedConfig->getCache()->getAll());
}
@ -299,7 +299,7 @@ abstract class ConfigTest extends MockedTest
->times(3);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertTrue($this->testedConfig->set('test', 'it', $data));
@ -317,7 +317,7 @@ abstract class ConfigTest extends MockedTest
$this->configModel->shouldReceive('set')->with('test', 'it', $data)->andReturn(true)->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertTrue($this->testedConfig->set('test', 'it', $data));
@ -331,7 +331,7 @@ abstract class ConfigTest extends MockedTest
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
// without refresh
self::assertNull($this->testedConfig->get('test', 'it'));
@ -353,10 +353,10 @@ abstract class ConfigTest extends MockedTest
*/
public function testGetWithRefresh($data)
{
$this->configCache->load(['test' => ['it' => 'now']], Cache\Cache::SOURCE_FILE);
$this->configCache->load(['test' => ['it' => 'now']], \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
// without refresh
self::assertEquals('now', $this->testedConfig->get('test', 'it'));
@ -378,10 +378,10 @@ abstract class ConfigTest extends MockedTest
*/
public function testDeleteWithoutDB($data)
{
$this->configCache->load(['test' => ['it' => $data]], Cache\Cache::SOURCE_FILE);
$this->configCache->load(['test' => ['it' => $data]], \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertEquals($data, $this->testedConfig->get('test', 'it'));
self::assertEquals($data, $this->testedConfig->getCache()->get('test', 'it'));
@ -398,7 +398,7 @@ abstract class ConfigTest extends MockedTest
*/
public function testDeleteWithDB()
{
$this->configCache->load(['test' => ['it' => 'now', 'quarter' => 'true']], Cache\Cache::SOURCE_FILE);
$this->configCache->load(['test' => ['it' => 'now', 'quarter' => 'true']], \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
$this->configModel->shouldReceive('delete')
->with('test', 'it')
@ -418,7 +418,7 @@ abstract class ConfigTest extends MockedTest
->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set('test', 'it', 'now');
@ -444,9 +444,9 @@ abstract class ConfigTest extends MockedTest
public function testSetGetHighPrio()
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
$this->testedConfig->getCache()->set('config', 'test', 'prio', Cache\Cache::SOURCE_FILE);
$this->testedConfig->getCache()->set('config', 'test', 'prio', \Friendica\Core\Config\ValueObject\Cache::SOURCE_FILE);
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
@ -460,10 +460,10 @@ abstract class ConfigTest extends MockedTest
public function testSetGetLowPrio()
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\Config\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertEquals('it', $this->testedConfig->get('config', 'test'));
$this->testedConfig->getCache()->set('config', 'test', 'prio', Cache\Cache::SOURCE_ENV);
$this->testedConfig->getCache()->set('config', 'test', 'prio', \Friendica\Core\Config\ValueObject\Cache::SOURCE_ENV);
// 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));

View file

@ -23,7 +23,7 @@
namespace Friendica\Core;
use Dice\Dice;
use Friendica\Core\Config\Cache\Cache;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\DI;
use Friendica\Network\IHTTPResult;
use Friendica\Network\IHTTPClient;

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Lock\Type\DatabaseLock;
use Friendica\Core\Config\Factory\ConfigFactory;
use Friendica\Core\Config\Factory\Config;
use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait;
@ -55,8 +55,8 @@ class DatabaseLockDriverTest extends LockTest
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
// load real config to avoid mocking every config-entry which is related to the Database class
$configFactory = new ConfigFactory();
$loader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), []);
$configFactory = new Config();
$loader = (new Config())->createConfigFileLoader($this->root->url(), []);
$configCache = $configFactory->createCache($loader);
$dba = new StaticDatabase($configCache, $profiler, $logger);

View file

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\Test\MockedTest;
abstract class LockTest extends MockedTest
@ -32,7 +32,7 @@ abstract class LockTest extends MockedTest
protected $startTime = 1417011228;
/**
* @var ILock
* @var ICanLock
*/
protected $instance;

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Lock;
use Exception;
use Friendica\Core\Cache\Type\MemcacheCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Lock\Type\CacheLock;
use Mockery;
@ -35,7 +35,7 @@ class MemcacheCacheLockTest extends LockTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHE_PORT'] ?? '11211';

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Lock;
use Exception;
use Friendica\Core\Cache\Type\MemcachedCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Lock\Type\CacheLock;
use Mockery;
use Psr\Log\NullLogger;
@ -36,7 +36,7 @@ class MemcachedCacheLockTest extends LockTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHED_PORT'] ?? '11211';

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Lock;
use Exception;
use Friendica\Core\Cache\Type\RedisCache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Lock\Type\CacheLock;
use Mockery;
@ -35,7 +35,7 @@ class RedisCacheLockTest extends LockTest
{
protected function getInstance()
{
$configMock = Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IManageConfigValues::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
$port = $_SERVER['REDIS_PORT'] ?? 6379;

View file

@ -23,7 +23,7 @@ namespace Friendica\Test\src\Core\Lock;
use Dice\Dice;
use Friendica\App;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Config\Type\JitConfig;
use Friendica\Core\Lock\Type\SemaphoreLock;
use Friendica\DI;
@ -46,7 +46,7 @@ class SemaphoreLockTest extends LockTest
->shouldReceive('get')
->with('system', 'temppath')
->andReturn('/tmp/');
$dice->shouldReceive('create')->with(IConfig::class)->andReturn($configMock);
$dice->shouldReceive('create')->with(IManageConfigValues::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
DI::init($dice);

View file

@ -47,7 +47,7 @@ class CacheTest extends MockedTest
];
}
private function assertConfigValues($data, Cache\Cache $configCache, $uid)
private function assertConfigValues($data, \Friendica\Core\PConfig\ValueObject\Cache $configCache, $uid)
{
foreach ($data as $cat => $values) {
foreach ($values as $key => $value) {
@ -63,7 +63,7 @@ class CacheTest extends MockedTest
*/
public function testSetGet($data)
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$uid = 345;
foreach ($data as $cat => $values) {
@ -81,7 +81,7 @@ class CacheTest extends MockedTest
*/
public function testGetCat()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$uid = 345;
$configCache->load($uid, [
@ -113,7 +113,7 @@ class CacheTest extends MockedTest
*/
public function testDelete($data)
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$uid = 345;
foreach ($data as $cat => $values) {
@ -136,7 +136,7 @@ class CacheTest extends MockedTest
*/
public function testKeyDiffWithResult()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$diffConfig = [
'fakeCat' => [
@ -154,7 +154,7 @@ class CacheTest extends MockedTest
*/
public function testKeyDiffWithoutResult($data)
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, $data);
@ -168,7 +168,7 @@ class CacheTest extends MockedTest
*/
public function testPasswordHide()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, [
'database' => [
@ -187,7 +187,7 @@ class CacheTest extends MockedTest
*/
public function testPasswordShow()
{
$configCache = new Cache\Cache(false);
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache(false);
$configCache->load(1, [
'database' => [
@ -206,7 +206,7 @@ class CacheTest extends MockedTest
*/
public function testEmptyPassword()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, [
'database' => [
@ -221,7 +221,7 @@ class CacheTest extends MockedTest
public function testWrongTypePassword()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, [
'database' => [
@ -233,7 +233,7 @@ class CacheTest extends MockedTest
self::assertNotEmpty($configCache->get(1, 'database', 'password'));
self::assertEmpty($configCache->get(1, 'database', 'username'));
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, [
'database' => [
@ -251,7 +251,7 @@ class CacheTest extends MockedTest
*/
public function testTwoUid()
{
$configCache = new Cache\Cache();
$configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
$configCache->load(1, [
'cat1' => [
@ -272,21 +272,4 @@ class CacheTest extends MockedTest
self::assertNull($configCache->get(1, 'cat2', 'key2'));
self::assertNull($configCache->get(2, 'cat1', 'key1'));
}
/**
* Test when using an invalid UID
* @todo check it the clean way before using the config class
*/
public function testInvalidUid()
{
// bad UID!
$uid = null;
$configCache = new Cache\Cache();
self::assertNull($configCache->get($uid, 'cat1', 'cat2'));
self::assertFalse($configCache->set($uid, 'cat1', 'key1', 'doesn\'t matter!'));
self::assertFalse($configCache->delete($uid, 'cat1', 'key1'));
}
}

View file

@ -22,8 +22,8 @@
namespace Friendica\Test\src\Core\PConfig;
use Friendica\Core\PConfig\Cache;
use Friendica\Core\PConfig\Type\BasePConfig;
use Friendica\Core\PConfig\Model\PConfig as PConfigModel;
use Friendica\Core\PConfig\Type\AbstractPConfigValues;
use Friendica\Core\PConfig\Repository\PConfig as PConfigModel;
use Friendica\Test\MockedTest;
use Mockery;
use Mockery\MockInterface;
@ -33,10 +33,10 @@ abstract class PConfigTest extends MockedTest
/** @var PConfigModel|MockInterface */
protected $configModel;
/** @var Cache\Cache */
/** @var \Friendica\Core\PConfig\ValueObject\Cache */
protected $configCache;
/** @var BasePConfig */
/** @var AbstractPConfigValues */
protected $testedConfig;
/**
@ -63,11 +63,11 @@ abstract class PConfigTest extends MockedTest
// Create the config model
$this->configModel = Mockery::mock(PConfigModel::class);
$this->configCache = new Cache\Cache();
$this->configCache = new \Friendica\Core\PConfig\ValueObject\Cache();
}
/**
* @return \Friendica\Core\PConfig\Type\BasePConfig
* @return \Friendica\Core\PConfig\Type\AbstractPConfigValues
*/
abstract public function getInstance();
@ -163,7 +163,7 @@ abstract class PConfigTest extends MockedTest
public function testSetUp()
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertEmpty($this->testedConfig->getCache()->getAll());
}
@ -174,7 +174,7 @@ abstract class PConfigTest extends MockedTest
public function testLoad(int $uid, array $data, array $possibleCats, array $load)
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
foreach ($load as $loadedCats) {
$this->testedConfig->load($uid, $loadedCats);
@ -257,7 +257,7 @@ abstract class PConfigTest extends MockedTest
public function testCacheLoadDouble(int $uid, array $data1, array $data2, array $expect)
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
foreach ($data1 as $cat => $data) {
$this->testedConfig->load($uid, $cat);
@ -281,7 +281,7 @@ abstract class PConfigTest extends MockedTest
public function testSetGetWithoutDB(int $uid, $data)
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
@ -302,7 +302,7 @@ abstract class PConfigTest extends MockedTest
->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertTrue($this->testedConfig->set($uid, 'test', 'it', $data));
@ -316,7 +316,7 @@ abstract class PConfigTest extends MockedTest
public function testGetWrongWithoutDB()
{
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
// without refresh
self::assertNull($this->testedConfig->get(0, 'test', 'it'));
@ -341,7 +341,7 @@ abstract class PConfigTest extends MockedTest
$this->configCache->load($uid, ['test' => ['it' => 'now']]);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
// without refresh
self::assertEquals('now', $this->testedConfig->get($uid, 'test', 'it'));
@ -366,7 +366,7 @@ abstract class PConfigTest extends MockedTest
$this->configCache->load($uid, ['test' => ['it' => $data]]);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertEquals($data, $this->testedConfig->get($uid, 'test', 'it'));
self::assertEquals($data, $this->testedConfig->getCache()->get($uid, 'test', 'it'));
@ -405,7 +405,7 @@ abstract class PConfigTest extends MockedTest
->once();
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
// directly set the value to the cache
$this->testedConfig->getCache()->set($uid, 'test', 'it', 'now');
@ -465,7 +465,7 @@ abstract class PConfigTest extends MockedTest
$this->configCache->load($data2['uid'], $data2['data']);
$this->testedConfig = $this->getInstance();
self::assertInstanceOf(Cache\Cache::class, $this->testedConfig->getCache());
self::assertInstanceOf(\Friendica\Core\PConfig\ValueObject\Cache::class, $this->testedConfig->getCache());
self::assertConfig($data1['uid'], 'cat1', $data1['data']['cat1']);
self::assertConfig($data1['uid'], 'cat2', $data1['data']['cat2']);

View file

@ -22,23 +22,22 @@
namespace Friendica\Test\src\Core;
use Dice\Dice;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Config\Type\PreloadConfig;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Session\ISession;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Type\Memory;
use Friendica\Core\StorageManager;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Core\Config\Factory\ConfigFactory;
use Friendica\Core\Config\Model\Config;
use Friendica\Core\Config\Factory\Config;
use Friendica\Core\Config\Repository;
use Friendica\Model\Storage;
use Friendica\Core\Session;
use Friendica\Network\HTTPClient;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait;
use Friendica\Core\Config\Cache\ConfigFileLoader;
use Friendica\Util\Profiler;
use org\bovigo\vfs\vfsStream;
use Psr\Log\LoggerInterface;
@ -50,7 +49,7 @@ class StorageManagerTest extends DatabaseTest
use VFSTrait;
/** @var Database */
private $dba;
/** @var IConfig */
/** @var IManageConfigValues */
private $config;
/** @var LoggerInterface */
private $logger;
@ -75,13 +74,13 @@ class StorageManagerTest extends DatabaseTest
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
// load real config to avoid mocking every config-entry which is related to the Database class
$configFactory = new ConfigFactory();
$configFactory = new Config();
$loader = $configFactory->createConfigFileLoader($this->root->url(), []);
$configCache = $configFactory->createCache($loader);
$this->dba = new StaticDatabase($configCache, $profiler, $this->logger);
$configModel = new Config($this->dba);
$configModel = new Repository\Config($this->dba);
$this->config = new PreloadConfig($configCache, $configModel);
$this->config->set('storage', 'name', 'Database');
$this->config->set('storage', 'filesystem_path', $this->root->getChild(Storage\FilesystemConfig::DEFAULT_BASE_FOLDER)->url());
@ -253,7 +252,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
->addRule(IHandleSessions::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
@ -281,7 +280,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
->addRule(IHandleSessions::class, ['instanceOf' => Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);

View file

@ -2,7 +2,7 @@
namespace Friendica\Test\src\Model;
use Friendica\Core\Config\Factory\ConfigFactory;
use Friendica\Core\Config\Factory\Config;
use Friendica\Model\Process;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase;
@ -31,8 +31,8 @@ class ProcessTest extends DatabaseTest
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
// load real config to avoid mocking every config-entry which is related to the Database class
$configFactory = new ConfigFactory();
$loader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), []);
$configFactory = new Config();
$loader = (new Config())->createConfigFileLoader($this->root->url(), []);
$configCache = $configFactory->createCache($loader);
$this->dba = new StaticDatabase($configCache, $profiler, $logger);

View file

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Model\Storage;
use Friendica\Core\Config\Factory\ConfigFactory;
use Friendica\Core\Config\Factory\Config;
use Friendica\Model\Storage\Database;
use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase;
@ -52,8 +52,8 @@ class DatabaseStorageTest extends StorageTest
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
// load real config to avoid mocking every config-entry which is related to the Database class
$configFactory = new ConfigFactory();
$loader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), []);
$configFactory = new Config();
$loader = (new Config())->createConfigFileLoader($this->root->url(), []);
$configCache = $configFactory->createCache($loader);
$dba = new StaticDatabase($configCache, $profiler, $logger);

View file

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Model\Storage;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Model\Storage\FilesystemConfig;
use Friendica\Model\Storage\IStorageConfiguration;
@ -46,7 +46,7 @@ class FilesystemStorageConfigTest extends StorageConfigTest
{
/** @var MockInterface|L10n $l10n */
$l10n = \Mockery::mock(L10n::class)->makePartial();
$config = \Mockery::mock(IConfig::class);
$config = \Mockery::mock(IManageConfigValues::class);
$config->shouldReceive('get')
->with('storage', 'filesystem_path', FilesystemConfig::DEFAULT_BASE_FOLDER)
->andReturn($this->root->getChild('storage')->url());

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Model\User;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Model\User\Cookie;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\StaticCookie;
@ -30,7 +30,7 @@ use Mockery\MockInterface;
class CookieTest extends MockedTest
{
/** @var MockInterface|IConfig */
/** @var MockInterface|\Friendica\Core\Config\Capability\IManageConfigValues */
private $config;
/** @var MockInterface|BaseURL */
private $baseUrl;
@ -41,7 +41,7 @@ class CookieTest extends MockedTest
parent::setUp();
$this->config = \Mockery::mock(IConfig::class);
$this->config = \Mockery::mock(IManageConfigValues::class);
$this->baseUrl = \Mockery::mock(BaseURL::class);
}

View file

@ -2,7 +2,7 @@
namespace Friendica\Test\src\Util;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Test\MockedTest;
class BaseURLTest extends MockedTest
@ -173,7 +173,7 @@ class BaseURLTest extends MockedTest
*/
public function testCheck($server, $input, $assert)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@ -295,7 +295,7 @@ class BaseURLTest extends MockedTest
*/
public function testSave($input, $save, $url)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@ -333,7 +333,7 @@ class BaseURLTest extends MockedTest
*/
public function testSaveByUrl($input, $save, $url)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
@ -409,7 +409,7 @@ class BaseURLTest extends MockedTest
*/
public function testGetURL($sslPolicy, $ssl, $url, $assert)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
@ -467,7 +467,7 @@ class BaseURLTest extends MockedTest
*/
public function testCheckRedirectHTTPS($server, $forceSSL, $sslPolicy, $url, $redirect)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
@ -503,7 +503,7 @@ class BaseURLTest extends MockedTest
*/
public function testWrongSave($fail)
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = \Mockery::mock(IManageConfigValues::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn(BaseURL::DEFAULT_SSL_SCHEME);

View file

@ -3,9 +3,9 @@
namespace Friendica\Test\src\Util;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\IPConfig;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Object\EMail\IEmail;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\EmailerSpy;
@ -26,9 +26,9 @@ class EMailerTest extends MockedTest
use VFSTrait;
use HookMockTrait;
/** @var IConfig|MockInterface */
/** @var \Friendica\Core\Config\Capability\IManageConfigValues|MockInterface */
private $config;
/** @var IPConfig|MockInterface */
/** @var \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues|MockInterface */
private $pConfig;
/** @var L10n|MockInterface */
private $l10n;
@ -41,12 +41,12 @@ class EMailerTest extends MockedTest
$this->setUpVfsDir();
$this->config = \Mockery::mock(IConfig::class);
$this->config = \Mockery::mock(IManageConfigValues::class);
$this->config->shouldReceive('get')->withArgs(['config', 'sender_email'])->andReturn('test@friendica.local')->once();
$this->config->shouldReceive('get')->withArgs(['config', 'sitename', 'Friendica Social Network'])->andReturn('Friendica Social Network')->once();
$this->config->shouldReceive('get')->withArgs(['system', 'sendmail_params', true])->andReturn(true);
$this->pConfig = \Mockery::mock(IPConfig::class);
$this->pConfig = \Mockery::mock(IManagePersonalConfigValues::class);
$this->l10n = \Mockery::mock(L10n::class);
$this->baseUrl = \Mockery::mock(BaseURL::class);
$this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Util\Emailer;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\EMail\IEmail;
@ -41,7 +41,7 @@ class MailBuilderTest extends MockedTest
{
use VFSTrait;
/** @var IConfig|MockInterface */
/** @var IManageConfigValues|MockInterface */
private $config;
/** @var L10n|MockInterface */
private $l10n;
@ -57,7 +57,7 @@ class MailBuilderTest extends MockedTest
$this->setUpVfsDir();
$this->config = \Mockery::mock(IConfig::class);
$this->config = \Mockery::mock(IManageConfigValues::class);
$this->l10n = \Mockery::mock(L10n::class);
$this->baseUrl = \Mockery::mock(BaseURL::class);
$this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');

View file

@ -22,7 +22,7 @@
namespace Friendica\Test\src\Util\Emailer;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
@ -34,7 +34,7 @@ class SystemMailBuilderTest extends MockedTest
{
use VFSTrait;
/** @var IConfig */
/** @var \Friendica\Core\Config\Capability\IManageConfigValues */
private $config;
/** @var L10n */
private $l10n;
@ -47,7 +47,7 @@ class SystemMailBuilderTest extends MockedTest
$this->setUpVfsDir();
$this->config = \Mockery::mock(IConfig::class);
$this->config = \Mockery::mock(IManageConfigValues::class);
$this->config->shouldReceive('get')->with('config', 'admin_name')->andReturn('Admin');
$this->l10n = \Mockery::mock(L10n::class);
$this->l10n->shouldReceive('t')->andReturnUsing(function ($msg) {

View file

@ -21,8 +21,8 @@
namespace Friendica\Test\src\Util;
use Friendica\Core\Config\Cache\Cache;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Test\MockedTest;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
@ -256,7 +256,7 @@ class ProfilerTest extends MockedTest
$profiler->saveTimestamp(time(), 'network', 'test1');
$config = \Mockery::mock(IConfig::class);
$config = \Mockery::mock(IManageConfigValues::class);
$config->shouldReceive('get')
->with('system', 'profiler')
->andReturn(false)