mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 01:25:21 +02:00
commit
17207dbb67
33 changed files with 909 additions and 330 deletions
|
@ -8,7 +8,7 @@
|
|||
namespace Friendica\Test;
|
||||
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
@ -124,7 +124,7 @@ abstract class ApiTestCase extends FixtureTestCase
|
|||
file_put_contents(
|
||||
$tmpFile,
|
||||
base64_decode(
|
||||
// Empty 1x1 px PNG image
|
||||
// Empty 1x1 px PNG image
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
|
||||
)
|
||||
);
|
||||
|
@ -201,7 +201,7 @@ abstract class ApiTestCase extends FixtureTestCase
|
|||
'plugin_admin' => function_exists($addon . '_addon_admin'),
|
||||
]);
|
||||
|
||||
Addon::loadAddons();
|
||||
$this->dice->create(AddonHelper::class)->loadAddons();
|
||||
Hook::loadHooks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ trait FixtureTestTrait
|
|||
->addRules(include __DIR__ . '/../static/dependencies.config.php')
|
||||
->addRule(ConfigFileManager::class, [
|
||||
'instanceOf' => Config::class,
|
||||
'call' => [['createConfigFileManager', [$this->root->url(), $server,], Dice::CHAIN_CALL]]])
|
||||
'call' => [['createConfigFileManager', [$this->root->url(), $this->root->url() . '/addon', $server,], Dice::CHAIN_CALL]]])
|
||||
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
|
||||
->addRule(IHandleSessions::class, ['instanceOf' => Memory::class, 'shared' => true, 'call' => null])
|
||||
->addRule(Arguments::class, [
|
||||
|
|
55
tests/Unit/Core/Addon/AddonInfoTest.php
Normal file
55
tests/Unit/Core/Addon/AddonInfoTest.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024, the Friendica project
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Friendica\Test\Unit\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon\AddonInfo;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AddonInfoTest extends TestCase
|
||||
{
|
||||
public function testFromArrayCreatesObject(): void
|
||||
{
|
||||
$data = [
|
||||
'id' => '',
|
||||
'name' => '',
|
||||
'description' => '',
|
||||
'authors' => [],
|
||||
'maintainers' => [],
|
||||
'version' => '',
|
||||
'status' => '',
|
||||
];
|
||||
|
||||
$this->assertInstanceOf(AddonInfo::class, AddonInfo::fromArray($data));
|
||||
}
|
||||
|
||||
public function testGetterReturningCorrectValues(): void
|
||||
{
|
||||
$data = [
|
||||
'id' => 'test',
|
||||
'name' => 'Test-Addon',
|
||||
'description' => 'This is an addon for tests',
|
||||
'authors' => [['name' => 'Sam']],
|
||||
'maintainers' => [['name' => 'Sam', 'link' => 'https://example.com']],
|
||||
'version' => '0.1',
|
||||
'status' => 'In Development',
|
||||
];
|
||||
|
||||
$info = AddonInfo::fromArray($data);
|
||||
|
||||
$this->assertSame($data['id'], $info->getId());
|
||||
$this->assertSame($data['name'], $info->getName());
|
||||
$this->assertSame($data['description'], $info->getDescription());
|
||||
$this->assertSame($data['description'], $info->getDescription());
|
||||
$this->assertSame($data['authors'], $info->getAuthors());
|
||||
$this->assertSame($data['maintainers'], $info->getMaintainers());
|
||||
$this->assertSame($data['version'], $info->getVersion());
|
||||
$this->assertSame($data['status'], $info->getStatus());
|
||||
}
|
||||
}
|
|
@ -15,8 +15,6 @@ use Friendica\Database\Definition\DbaDefinition;
|
|||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\Test\DatabaseTestTrait;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
trait CreateDatabaseTrait
|
||||
{
|
||||
|
@ -32,8 +30,13 @@ trait CreateDatabaseTrait
|
|||
return $this->dba;
|
||||
}
|
||||
|
||||
$configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
||||
$config = new ReadOnlyFileConfig(new Cache([
|
||||
$configFileManager = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
$this->root->url() . '/config',
|
||||
$this->root->url() . '/static'
|
||||
);
|
||||
$config = new ReadOnlyFileConfig(new Cache([
|
||||
'database' => [
|
||||
'disable_pdo' => true
|
||||
],
|
||||
|
|
|
@ -34,6 +34,7 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
|
@ -61,10 +62,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
}
|
||||
|
@ -90,10 +92,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -127,10 +130,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -163,10 +167,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -217,6 +222,7 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
|
@ -254,10 +260,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -288,10 +295,11 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
$configCache = new Cache();
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
|
@ -322,6 +330,7 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
|
||||
$configFileLoader = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . 'addon',
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::CONFIG_DIR,
|
||||
$this->root->url() . DIRECTORY_SEPARATOR . Config::STATIC_DIR
|
||||
);
|
||||
|
@ -341,8 +350,12 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
{
|
||||
$this->delConfigFile('local.config.php');
|
||||
|
||||
$configFileManager = (new Config())->createConfigFileManager($this->root->url(), ['FRIENDICA_CONFIG_DIR' => '/a/wrong/dir/']);
|
||||
$configCache = new Cache();
|
||||
$configFileManager = (new Config())->createConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
['FRIENDICA_CONFIG_DIR' => '/a/wrong/dir/'],
|
||||
);
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileManager->setupCache($configCache);
|
||||
|
||||
|
@ -367,11 +380,12 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
->at($this->root->getChild('config2'))
|
||||
->setContent(file_get_contents($fileDir . 'B.config.php'));
|
||||
|
||||
$configFileManager = (new Config())->createConfigFileManager($this->root->url(),
|
||||
[
|
||||
'FRIENDICA_CONFIG_DIR' => $this->root->getChild('config2')->url(),
|
||||
]);
|
||||
$configCache = new Cache();
|
||||
$configFileManager = (new Config())->createConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
['FRIENDICA_CONFIG_DIR' => $this->root->getChild('config2')->url()],
|
||||
);
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileManager->setupCache($configCache);
|
||||
|
||||
|
@ -389,11 +403,12 @@ class ConfigFileManagerTest extends MockedTestCase
|
|||
->at($this->root->getChild('config'))
|
||||
->setContent('');
|
||||
|
||||
$configFileManager = (new Config())->createConfigFileManager($this->root->url());
|
||||
$configCache = new Cache();
|
||||
$configFileManager = (new Config())->createConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
);
|
||||
$configCache = new Cache();
|
||||
|
||||
$configFileManager->setupCache($configCache);
|
||||
|
||||
self::assertEquals(1,1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use Friendica\Core\Config\ValueObject\Cache;
|
|||
use Friendica\Test\DatabaseTestCase;
|
||||
use Friendica\Test\Util\CreateDatabaseTrait;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class ConfigTest extends DatabaseTestCase
|
||||
{
|
||||
|
@ -55,8 +54,13 @@ class ConfigTest extends DatabaseTestCase
|
|||
|
||||
parent::setUp();
|
||||
|
||||
$this->configCache = new Cache();
|
||||
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
||||
$this->configCache = new Cache();
|
||||
$this->configFileManager = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
$this->root->url() . '/config',
|
||||
$this->root->url() . '/static'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,7 +98,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
'key1' => 'value1a',
|
||||
'key4' => 'value4',
|
||||
],
|
||||
'other' => [
|
||||
'other' => [
|
||||
'key5' => 'value5',
|
||||
'key6' => 'value6',
|
||||
],
|
||||
|
@ -108,18 +112,18 @@ class ConfigTest extends DatabaseTestCase
|
|||
'config',
|
||||
'other'
|
||||
],
|
||||
'load' => [
|
||||
'load' => [
|
||||
'system',
|
||||
],
|
||||
],
|
||||
'other' => [
|
||||
'other' => [
|
||||
'data' => $data,
|
||||
'possibleCats' => [
|
||||
'system',
|
||||
'config',
|
||||
'other'
|
||||
],
|
||||
'load' => [
|
||||
'load' => [
|
||||
'other',
|
||||
],
|
||||
],
|
||||
|
@ -130,18 +134,18 @@ class ConfigTest extends DatabaseTestCase
|
|||
'config',
|
||||
'other'
|
||||
],
|
||||
'load' => [
|
||||
'load' => [
|
||||
'config',
|
||||
],
|
||||
],
|
||||
'all' => [
|
||||
'all' => [
|
||||
'data' => $data,
|
||||
'possibleCats' => [
|
||||
'system',
|
||||
'config',
|
||||
'other'
|
||||
],
|
||||
'load' => [
|
||||
'load' => [
|
||||
'system',
|
||||
'config',
|
||||
'other'
|
||||
|
@ -173,7 +177,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
*/
|
||||
public function testSetUp(array $data)
|
||||
{
|
||||
$this->loadDirectFixture($this->configToDbArray($data) , $this->getDbInstance());
|
||||
$this->loadDirectFixture($this->configToDbArray($data), $this->getDbInstance());
|
||||
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
@ -209,13 +213,13 @@ class ConfigTest extends DatabaseTestCase
|
|||
{
|
||||
return [
|
||||
'config' => [
|
||||
'data1' => [
|
||||
'data1' => [
|
||||
'config' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
],
|
||||
],
|
||||
'data2' => [
|
||||
'data2' => [
|
||||
'config' => [
|
||||
'key1' => 'overwritten!',
|
||||
'key3' => 'value3',
|
||||
|
@ -230,19 +234,19 @@ class ConfigTest extends DatabaseTestCase
|
|||
],
|
||||
],
|
||||
],
|
||||
'other' => [
|
||||
'data1' => [
|
||||
'other' => [
|
||||
'data1' => [
|
||||
'config' => [
|
||||
'key12' => 'data4',
|
||||
'key45' => 7,
|
||||
],
|
||||
'other' => [
|
||||
'other' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
],
|
||||
],
|
||||
'data2' => [
|
||||
'other' => [
|
||||
'data2' => [
|
||||
'other' => [
|
||||
'key1' => 'overwritten!',
|
||||
'key3' => 'value3',
|
||||
],
|
||||
|
@ -252,7 +256,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
]
|
||||
],
|
||||
'expect' => [
|
||||
'other' => [
|
||||
'other' => [
|
||||
// load should overwrite values everytime!
|
||||
'key1' => 'overwritten!',
|
||||
'key2' => 'value2',
|
||||
|
@ -399,26 +403,26 @@ class ConfigTest extends DatabaseTestCase
|
|||
public function dataTestCat()
|
||||
{
|
||||
return [
|
||||
'test_with_hashmap' => [
|
||||
'data' => [
|
||||
'test_with_hashmap' => [
|
||||
'data' => [
|
||||
'test_with_hashmap' => [
|
||||
'notifyall' => [
|
||||
'last_update' => 1671051565,
|
||||
'admin' => true,
|
||||
],
|
||||
'blockbot' => [
|
||||
'blockbot' => [
|
||||
'last_update' => 1658952852,
|
||||
'admin' => true,
|
||||
],
|
||||
],
|
||||
'config' => [
|
||||
'config' => [
|
||||
'register_policy' => 2,
|
||||
'register_text' => '',
|
||||
'sitename' => 'Friendica Social Network23',
|
||||
'hostname' => 'friendica.local',
|
||||
'private_addons' => false,
|
||||
],
|
||||
'system' => [
|
||||
'system' => [
|
||||
'dbclean_expire_conversation' => 90,
|
||||
],
|
||||
],
|
||||
|
@ -428,14 +432,14 @@ class ConfigTest extends DatabaseTestCase
|
|||
'last_update' => 1671051565,
|
||||
'admin' => true,
|
||||
],
|
||||
'blockbot' => [
|
||||
'blockbot' => [
|
||||
'last_update' => 1658952852,
|
||||
'admin' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
'test_with_keys' => [
|
||||
'data' => [
|
||||
'test_with_keys' => [
|
||||
'data' => [
|
||||
'test_with_keys' => [
|
||||
[
|
||||
'last_update' => 1671051565,
|
||||
|
@ -446,14 +450,14 @@ class ConfigTest extends DatabaseTestCase
|
|||
'admin' => true,
|
||||
],
|
||||
],
|
||||
'config' => [
|
||||
'config' => [
|
||||
'register_policy' => 2,
|
||||
'register_text' => '',
|
||||
'sitename' => 'Friendica Social Network23',
|
||||
'hostname' => 'friendica.local',
|
||||
'private_addons' => false,
|
||||
],
|
||||
'system' => [
|
||||
'system' => [
|
||||
'dbclean_expire_conversation' => 90,
|
||||
],
|
||||
],
|
||||
|
@ -470,7 +474,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
],
|
||||
],
|
||||
'test_with_inner_array' => [
|
||||
'data' => [
|
||||
'data' => [
|
||||
'test_with_inner_array' => [
|
||||
'notifyall' => [
|
||||
'last_update' => 1671051565,
|
||||
|
@ -479,19 +483,19 @@ class ConfigTest extends DatabaseTestCase
|
|||
'no' => 1.5,
|
||||
],
|
||||
],
|
||||
'blogbot' => [
|
||||
'blogbot' => [
|
||||
'last_update' => 1658952852,
|
||||
'admin' => true,
|
||||
],
|
||||
],
|
||||
'config' => [
|
||||
'config' => [
|
||||
'register_policy' => 2,
|
||||
'register_text' => '',
|
||||
'sitename' => 'Friendica Social Network23',
|
||||
'hostname' => 'friendica.local',
|
||||
'private_addons' => false,
|
||||
],
|
||||
'system' => [
|
||||
'system' => [
|
||||
'dbclean_expire_conversation' => 90,
|
||||
],
|
||||
],
|
||||
|
@ -504,7 +508,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
'no' => 1.5,
|
||||
],
|
||||
],
|
||||
'blogbot' => [
|
||||
'blogbot' => [
|
||||
'last_update' => 1658952852,
|
||||
'admin' => true,
|
||||
],
|
||||
|
@ -519,7 +523,7 @@ class ConfigTest extends DatabaseTestCase
|
|||
public function testGetCategory(array $data, string $category, array $assertion)
|
||||
{
|
||||
$this->configCache = new Cache($data);
|
||||
$config = new ReadOnlyFileConfig($this->configCache);
|
||||
$config = new ReadOnlyFileConfig($this->configCache);
|
||||
|
||||
self::assertEquals($assertion, $config->get($category));
|
||||
}
|
||||
|
@ -528,15 +532,15 @@ class ConfigTest extends DatabaseTestCase
|
|||
{
|
||||
return [
|
||||
'default' => [
|
||||
'value' => ['test' => ['array']],
|
||||
'value' => ['test' => ['array']],
|
||||
'assertion' => ['test' => ['array']],
|
||||
],
|
||||
'issue-12803' => [
|
||||
'value' => 's:48:"s:40:"s:32:"https://punkrock-underground.com";";";',
|
||||
'value' => 's:48:"s:40:"s:32:"https://punkrock-underground.com";";";',
|
||||
'assertion' => 'https://punkrock-underground.com',
|
||||
],
|
||||
'double-serialized-array' => [
|
||||
'value' => 's:53:"a:1:{s:9:"testArray";a:1:{s:4:"with";s:7:"entries";}}";',
|
||||
'value' => 's:53:"a:1:{s:9:"testArray";a:1:{s:4:"with";s:7:"entries";}}";',
|
||||
'assertion' => ['testArray' => ['with' => 'entries']],
|
||||
],
|
||||
];
|
||||
|
@ -558,33 +562,33 @@ class ConfigTest extends DatabaseTestCase
|
|||
$data = [
|
||||
'config' => [
|
||||
'admin_email' => 'value1',
|
||||
'timezone' => 'value2',
|
||||
'language' => 'value3',
|
||||
'sitename' => 'value',
|
||||
'timezone' => 'value2',
|
||||
'language' => 'value3',
|
||||
'sitename' => 'value',
|
||||
],
|
||||
'system' => [
|
||||
'url' => 'value1a',
|
||||
'url' => 'value1a',
|
||||
'debugging' => true,
|
||||
'logfile' => 'value4',
|
||||
'loglevel' => 'notice',
|
||||
'proflier' => true,
|
||||
'logfile' => 'value4',
|
||||
'loglevel' => 'notice',
|
||||
'proflier' => true,
|
||||
],
|
||||
'proxy' => [
|
||||
'proxy' => [
|
||||
'trusted_proxies' => 'value5',
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'empty' => [
|
||||
'data' => $data,
|
||||
'server' => [],
|
||||
'data' => $data,
|
||||
'server' => [],
|
||||
'assertDisabled' => [],
|
||||
],
|
||||
'mixed' => [
|
||||
'data' => $data,
|
||||
'server' => [
|
||||
'FRIENDICA_ADMIN_MAIL' => 'test@friendica.local',
|
||||
'FRIENDICA_DEBUGGING' => true,
|
||||
'FRIENDICA_DEBUGGING' => true,
|
||||
],
|
||||
'assertDisabled' => [
|
||||
'config' => [
|
||||
|
@ -608,7 +612,13 @@ class ConfigTest extends DatabaseTestCase
|
|||
$this->setConfigFile('static' . DIRECTORY_SEPARATOR . 'env.config.php', true);
|
||||
$this->loadDirectFixture($this->configToDbArray($data), $this->getDbInstance());
|
||||
|
||||
$configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/', $server);
|
||||
$configFileManager = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
$this->root->url() . '/config',
|
||||
$this->root->url() . '/static',
|
||||
$server
|
||||
);
|
||||
$configFileManager->setupCache($this->configCache);
|
||||
$config = new DatabaseConfig($this->getDbInstance(), $this->configCache);
|
||||
|
||||
|
|
|
@ -9,16 +9,11 @@ namespace Friendica\Test\src\Core\Config;
|
|||
|
||||
use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
|
||||
use Friendica\Core\Config\Model\DatabaseConfig;
|
||||
use Friendica\Core\Config\Model\ReadOnlyFileConfig;
|
||||
use Friendica\Core\Config\Model\ConfigTransaction;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Core\Config\ValueObject\Cache;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Test\DatabaseTestCase;
|
||||
use Friendica\Test\FixtureTestCase;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Mockery\Exception\InvalidCountException;
|
||||
|
||||
class ConfigTransactionTest extends FixtureTestCase
|
||||
|
@ -30,7 +25,12 @@ class ConfigTransactionTest extends FixtureTestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
||||
$this->configFileManager = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
$this->root->url() . '/config',
|
||||
$this->root->url() . '/static'
|
||||
);
|
||||
}
|
||||
|
||||
public function dataTests(): array
|
||||
|
@ -96,7 +96,7 @@ class ConfigTransactionTest extends FixtureTestCase
|
|||
{
|
||||
$this->configFileManager = \Mockery::spy(ConfigFileManager::class);
|
||||
|
||||
$config = new DatabaseConfig($this->dice->create(Database::class), new Cache());
|
||||
$config = new DatabaseConfig($this->dice->create(Database::class), new Cache());
|
||||
$configTransaction = new ConfigTransaction($config);
|
||||
|
||||
// commit empty transaction
|
||||
|
|
|
@ -21,16 +21,12 @@ use Friendica\Core\Storage\Repository\StorageManager;
|
|||
use Friendica\Core\Storage\Type\Filesystem;
|
||||
use Friendica\Core\Storage\Type\SystemResource;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\Definition\DbaDefinition;
|
||||
use Friendica\Database\Definition\ViewDefinition;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Core\Storage\Type;
|
||||
use Friendica\Test\DatabaseTestCase;
|
||||
use Friendica\Test\Util\CreateDatabaseTrait;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Util\Profiler;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
|
@ -60,12 +56,15 @@ class StorageManagerTest extends DatabaseTestCase
|
|||
|
||||
vfsStream::newDirectory(Type\FilesystemConfig::DEFAULT_BASE_FOLDER, 0777)->at($this->root);
|
||||
|
||||
$this->logger = new NullLogger();
|
||||
$this->logger = new NullLogger();
|
||||
$this->database = $this->getDbInstance();
|
||||
|
||||
$configFactory = new Config();
|
||||
$configFileManager = $configFactory->createConfigFileManager($this->root->url());
|
||||
$configCache = $configFactory->createCache($configFileManager);
|
||||
$configFileManager = $configFactory->createConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
);
|
||||
$configCache = $configFactory->createCache($configFileManager);
|
||||
|
||||
$this->config = new \Friendica\Core\Config\Model\DatabaseConfig($this->database, $configCache);
|
||||
$this->config->set('storage', 'name', 'Database');
|
||||
|
@ -96,21 +95,21 @@ class StorageManagerTest extends DatabaseTestCase
|
|||
public function dataStorages()
|
||||
{
|
||||
return [
|
||||
'empty' => [
|
||||
'empty' => [
|
||||
'name' => '',
|
||||
'valid' => false,
|
||||
'interface' => ICanReadFromStorage::class,
|
||||
'assert' => null,
|
||||
'assertName' => '',
|
||||
],
|
||||
'database' => [
|
||||
'database' => [
|
||||
'name' => Type\Database::NAME,
|
||||
'valid' => true,
|
||||
'interface' => ICanWriteToStorage::class,
|
||||
'assert' => Type\Database::class,
|
||||
'assertName' => Type\Database::NAME,
|
||||
],
|
||||
'filesystem' => [
|
||||
'filesystem' => [
|
||||
'name' => Filesystem::NAME,
|
||||
'valid' => true,
|
||||
'interface' => ICanWriteToStorage::class,
|
||||
|
@ -124,7 +123,7 @@ class StorageManagerTest extends DatabaseTestCase
|
|||
'assert' => SystemResource::class,
|
||||
'assertName' => SystemResource::NAME,
|
||||
],
|
||||
'invalid' => [
|
||||
'invalid' => [
|
||||
'name' => 'invalid',
|
||||
'valid' => false,
|
||||
'interface' => null,
|
||||
|
|
|
@ -32,7 +32,12 @@ class DatabaseTest extends FixtureTestCase
|
|||
parent::setUp();
|
||||
|
||||
$this->configCache = new Cache();
|
||||
$this->configFileManager = new ConfigFileManager($this->root->url(), $this->root->url() . '/config/', $this->root->url() . '/static/');
|
||||
$this->configFileManager = new ConfigFileManager(
|
||||
$this->root->url(),
|
||||
$this->root->url() . '/addon',
|
||||
$this->root->url() . '/config',
|
||||
$this->root->url() . '/static'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +92,7 @@ class DatabaseTest extends FixtureTestCase
|
|||
|
||||
self::assertTrue($db->update('gserver', ['active-week-users' => 0, 'registered-users' => 0], ['nurl' => 'http://friendica.local']));
|
||||
|
||||
$fields = ["`registered-users` = `registered-users` + 1"];
|
||||
$fields = ["`registered-users` = `registered-users` + 1"];
|
||||
$fields[] = "`active-week-users` = `active-week-users` + 2";
|
||||
|
||||
self::assertTrue($db->update('gserver', $fields, ['nurl' => 'http://friendica.local']));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue