mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 15:54:26 +02:00
Merge 4bac217806
into e3a00dfa8d
This commit is contained in:
commit
2c57170ea6
9 changed files with 283 additions and 81 deletions
13
src/App.php
13
src/App.php
|
@ -18,7 +18,6 @@ use Friendica\Capabilities\ICanCreateResponses;
|
|||
use Friendica\Capabilities\ICanHandleRequests;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Addon\AddonHelper;
|
||||
use Friendica\Core\Addon\Capability\ICanLoadAddons;
|
||||
use Friendica\Core\Config\Factory\Config;
|
||||
use Friendica\Core\Container;
|
||||
use Friendica\Core\Hooks\HookEventBridge;
|
||||
|
@ -278,11 +277,15 @@ class App
|
|||
|
||||
private function setupContainerForAddons(): void
|
||||
{
|
||||
/** @var ICanLoadAddons $addonLoader */
|
||||
$addonLoader = $this->container->create(ICanLoadAddons::class);
|
||||
/** @var AddonHelper $addonHelper */
|
||||
$addonHelper = $this->container->create(AddonHelper::class);
|
||||
|
||||
foreach ($addonLoader->getActiveAddonConfig('dependencies') as $name => $rule) {
|
||||
$this->container->addRule($name, $rule);
|
||||
$addonHelper->loadAddons();
|
||||
|
||||
foreach ($addonHelper->getEnabledAddons() as $addonId) {
|
||||
foreach ($addonHelper->getAddonDependencyConfig($addonId) as $name => $rule) {
|
||||
$this->container->addRule($name, $rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
|
||||
|
||||
/**
|
||||
* Some functions to handle addons
|
||||
*/
|
||||
|
@ -66,6 +68,17 @@ interface AddonHelper
|
|||
*/
|
||||
public function getAddonInfo(string $addonId): AddonInfo;
|
||||
|
||||
/**
|
||||
* Returns a dependency config array for a given addon
|
||||
*
|
||||
* This will load a potential config-file from the static directory, like `addon/{addonId}/static/dependencies.config.php`
|
||||
*
|
||||
* @throws AddonInvalidConfigFileException If the config file doesn't return an array
|
||||
*
|
||||
* @return array the config as array or empty array if no config file was found
|
||||
*/
|
||||
public function getAddonDependencyConfig(string $addonId): array;
|
||||
|
||||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Friendica\Core\Addon;
|
||||
|
||||
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
|
||||
use Friendica\Core\Addon\Exception\InvalidAddonException;
|
||||
use Friendica\Core\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
|
@ -270,6 +271,34 @@ final class AddonManagerHelper implements AddonHelper
|
|||
return AddonInfo::fromString($addonId, $matches[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a dependency config array for a given addon
|
||||
*
|
||||
* This will load a potential config-file from the static directory, like `addon/{addonId}/static/dependencies.config.php`
|
||||
*
|
||||
* @throws AddonInvalidConfigFileException If the config file doesn't return an array
|
||||
*
|
||||
* @return array the config as array or empty array if no config file was found
|
||||
*/
|
||||
public function getAddonDependencyConfig(string $addonId): array
|
||||
{
|
||||
$addonId = Strings::sanitizeFilePathItem(trim($addonId));
|
||||
|
||||
$configFile = $this->getAddonPath() . '/' . $addonId . '/static/dependencies.config.php';
|
||||
|
||||
if (!file_exists($configFile)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$config = include($configFile);
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new AddonInvalidConfigFileException('Error loading config file ' . $configFile);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided addon is enabled
|
||||
*/
|
||||
|
|
|
@ -9,12 +9,16 @@ namespace Friendica\Core\Addon\Capability;
|
|||
|
||||
/**
|
||||
* Interface for loading Addons specific content
|
||||
*
|
||||
* @deprecated 2025.02 Use implementation of `\Friendica\Core\Addon\AddonHelper` instead.
|
||||
*/
|
||||
interface ICanLoadAddons
|
||||
{
|
||||
/**
|
||||
* Returns a merged config array of all active addons for a given config-name
|
||||
*
|
||||
* @deprecated 2025.02 Use `\Friendica\Core\Addon\AddonHelper::getAddonDependencyConfig()` instead.
|
||||
*
|
||||
* @param string $configName The config-name (config-file at the static directory, like 'hooks' => '{addon}/static/hooks.config.php)
|
||||
*
|
||||
* @return array the merged array
|
||||
|
|
|
@ -14,6 +14,9 @@ use Friendica\Core\Logger\Factory\LoggerFactory;
|
|||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @deprecated 2025.02 Use implementation of `\Friendica\Core\Addon\AddonHelper` instead.
|
||||
*/
|
||||
class AddonLoader implements ICanLoadAddons
|
||||
{
|
||||
const STATIC_PATH = 'static';
|
||||
|
@ -24,13 +27,19 @@ class AddonLoader implements ICanLoadAddons
|
|||
|
||||
public function __construct(string $basePath, IManageConfigValues $config)
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use implementation of `Friendica\Core\Addon\AddonHelper` instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->basePath = $basePath;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
/**
|
||||
* @deprecated 2025.02 Use `\Friendica\Core\Addon\AddonHelper::getAddonDependencyConfig()` instead.
|
||||
*/
|
||||
public function getActiveAddonConfig(string $configName): array
|
||||
{
|
||||
@trigger_error('Class `' . __CLASS__ . '` is deprecated since 2025.02 and will be removed after 5 months, use `\Friendica\Core\Addon\AddonHelper::getAddonDependencyConfig()` instead.', E_USER_DEPRECATED);
|
||||
|
||||
$addons = array_keys(array_filter($this->config->get('addons') ?? []));
|
||||
$returnConfig = [];
|
||||
|
||||
|
|
|
@ -7,9 +7,13 @@
|
|||
|
||||
namespace Friendica\Core\Hooks\Util;
|
||||
|
||||
use Friendica\Core\Addon\Capability\ICanLoadAddons;
|
||||
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
|
||||
use Friendica\Core\Hooks\Exceptions\HookConfigException;
|
||||
use Friendica\Core\Logger\Factory\LoggerFactory;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Manage all strategies.config.php files
|
||||
|
@ -24,17 +28,15 @@ class StrategiesFileManager
|
|||
const STATIC_DIR = 'static';
|
||||
const CONFIG_NAME = 'strategies';
|
||||
|
||||
/** @var ICanLoadAddons */
|
||||
protected $addonLoader;
|
||||
/** @var array */
|
||||
protected $config = [];
|
||||
private IManageConfigValues $configuration;
|
||||
protected array $config = [];
|
||||
/** @var string */
|
||||
protected $basePath;
|
||||
|
||||
public function __construct(string $basePath, ICanLoadAddons $addonLoader)
|
||||
public function __construct(string $basePath, IManageConfigValues $configuration)
|
||||
{
|
||||
$this->basePath = $basePath;
|
||||
$this->addonLoader = $addonLoader;
|
||||
$this->basePath = $basePath;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,6 +86,50 @@ class StrategiesFileManager
|
|||
/**
|
||||
* @deprecated 2025.02 Providing strategies via addons is deprecated and will be removed in 5 months.
|
||||
*/
|
||||
$this->config = array_merge_recursive($config, $this->addonLoader->getActiveAddonConfig(static::CONFIG_NAME));
|
||||
$this->config = array_merge_recursive($config, $this->getActiveAddonConfig());
|
||||
}
|
||||
|
||||
private function getActiveAddonConfig(): array
|
||||
{
|
||||
$addons = array_keys(array_filter($this->configuration->get('addons') ?? []));
|
||||
$returnConfig = [];
|
||||
|
||||
foreach ($addons as $addon) {
|
||||
$addonName = Strings::sanitizeFilePathItem(trim($addon));
|
||||
|
||||
$configFile = $this->basePath . '/addon/' . $addonName . '/' . static::STATIC_DIR . '/strategies.config.php';
|
||||
|
||||
if (!file_exists($configFile)) {
|
||||
// Addon unmodified, skipping
|
||||
continue;
|
||||
}
|
||||
|
||||
$config = include $configFile;
|
||||
|
||||
if (!is_array($config)) {
|
||||
throw new AddonInvalidConfigFileException('Error loading config file ' . $configFile);
|
||||
}
|
||||
|
||||
foreach ($config as $classname => $rule) {
|
||||
if ($classname === LoggerInterface::class) {
|
||||
@trigger_error(sprintf(
|
||||
'Providing a strategy for `%s` is deprecated since 2025.02 and will stop working in 5 months, please provide an implementation for `%s` via `dependency.config.php` and remove the `strategies.config.php` file in the `%s` addon.',
|
||||
$classname,
|
||||
LoggerFactory::class,
|
||||
$addonName,
|
||||
), \E_USER_DEPRECATED);
|
||||
} else {
|
||||
@trigger_error(sprintf(
|
||||
'Providing strategies for `%s` via addons is deprecated since 2025.02 and will stop working in 5 months, please stop using this and remove the `strategies.config.php` file in the `%s` addon.',
|
||||
$classname,
|
||||
$addonName,
|
||||
), \E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
$returnConfig = array_merge_recursive($returnConfig, $config);
|
||||
}
|
||||
|
||||
return $returnConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo
|
|||
'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class,
|
||||
'constructParams' => [
|
||||
$basepath,
|
||||
[Dice::INSTANCE => Dice::SELF],
|
||||
],
|
||||
],
|
||||
\Friendica\Core\Addon\AddonHelper::class => [
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Friendica\Test\Unit\Core\Addon;
|
|||
use Exception;
|
||||
use Friendica\Core\Addon\AddonInfo;
|
||||
use Friendica\Core\Addon\AddonManagerHelper;
|
||||
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
|
||||
use Friendica\Core\Addon\Exception\InvalidAddonException;
|
||||
use Friendica\Core\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
|
@ -81,6 +82,76 @@ class AddonManagerHelperTest extends TestCase
|
|||
$addonManagerHelper->getAddonInfo('helloaddon');
|
||||
}
|
||||
|
||||
public function testGetAddonDependencyConfigReturnsArray(): void
|
||||
{
|
||||
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
|
||||
'helloaddon' => [
|
||||
'static' => [
|
||||
'dependencies.config.php' => <<<PHP
|
||||
<?php
|
||||
return [
|
||||
'foo' => 'bar',
|
||||
];
|
||||
PHP,
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$addonManagerHelper = new AddonManagerHelper(
|
||||
$root->url(),
|
||||
$this->createStub(Database::class),
|
||||
$this->createStub(IManageConfigValues::class),
|
||||
$this->createStub(ICanCache::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(Profiler::class)
|
||||
);
|
||||
|
||||
$this->assertSame(['foo' => 'bar'], $addonManagerHelper->getAddonDependencyConfig('helloaddon'));
|
||||
}
|
||||
|
||||
public function testGetAddonDependencyConfigWithoutConfigFileReturnsEmptyArray(): void
|
||||
{
|
||||
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
|
||||
'helloaddon' => []
|
||||
]);
|
||||
|
||||
$addonManagerHelper = new AddonManagerHelper(
|
||||
$root->url(),
|
||||
$this->createStub(Database::class),
|
||||
$this->createStub(IManageConfigValues::class),
|
||||
$this->createStub(ICanCache::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(Profiler::class)
|
||||
);
|
||||
|
||||
$this->assertSame([], $addonManagerHelper->getAddonDependencyConfig('helloaddon'));
|
||||
}
|
||||
|
||||
public function testGetAddonDependencyConfigWithoutReturningAnArrayThrowsException(): void
|
||||
{
|
||||
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
|
||||
'helloaddon' => [
|
||||
'static' => [
|
||||
'dependencies.config.php' => '<?php return null;',
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$addonManagerHelper = new AddonManagerHelper(
|
||||
$root->url(),
|
||||
$this->createStub(Database::class),
|
||||
$this->createStub(IManageConfigValues::class),
|
||||
$this->createStub(ICanCache::class),
|
||||
$this->createStub(LoggerInterface::class),
|
||||
$this->createStub(Profiler::class)
|
||||
);
|
||||
|
||||
$this->expectException(AddonInvalidConfigFileException::class);
|
||||
$this->expectExceptionMessageMatches('#Error loading config file .+/helloaddon/static/dependencies\.config\.php#');
|
||||
|
||||
$addonManagerHelper->getAddonDependencyConfig('helloaddon');
|
||||
}
|
||||
|
||||
public function testEnabledAddons(): void
|
||||
{
|
||||
$config = $this->createStub(IManageConfigValues::class);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Hooks\Util;
|
||||
|
||||
use Friendica\Core\Addon\Capability\ICanLoadAddons;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
|
||||
use Friendica\Core\Hooks\Exceptions\HookConfigException;
|
||||
use Friendica\Core\Hooks\Util\StrategiesFileManager;
|
||||
|
@ -33,49 +33,61 @@ class StrategiesFileManagerTest extends MockedTestCase
|
|||
return [
|
||||
'normal' => [
|
||||
'content' => <<<EOF
|
||||
<?php
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonsArray' => [],
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonContent' => <<<EOF
|
||||
<?php
|
||||
|
||||
return [];
|
||||
EOF,
|
||||
'assertStrategies' => [
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
],
|
||||
],
|
||||
'normalWithString' => [
|
||||
'content' => <<<EOF
|
||||
<?php
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => '',
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonsArray' => [],
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => '',
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonContent' => <<<EOF
|
||||
<?php
|
||||
|
||||
return [];
|
||||
EOF,
|
||||
'assertStrategies' => [
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
],
|
||||
],
|
||||
'withAddons' => [
|
||||
'content' => <<<EOF
|
||||
<?php
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonsArray' => [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => ['null'],
|
||||
],
|
||||
],
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonContent' => <<<EOF
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => ['null'],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'assertStrategies' => [
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
[LoggerInterface::class, NullLogger::class, 'null'],
|
||||
|
@ -83,19 +95,23 @@ EOF,
|
|||
],
|
||||
'withAddonsWithString' => [
|
||||
'content' => <<<EOF
|
||||
<?php
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonsArray' => [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => 'null',
|
||||
],
|
||||
],
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonContent' => <<<EOF
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => ['null'],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'assertStrategies' => [
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
[LoggerInterface::class, NullLogger::class, 'null'],
|
||||
|
@ -104,19 +120,23 @@ EOF,
|
|||
// This should work because unique name convention is part of the instance manager logic, not of the file-infrastructure layer
|
||||
'withAddonsDoubleNamed' => [
|
||||
'content' => <<<EOF
|
||||
<?php
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonsArray' => [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
],
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'addonContent' => <<<EOF
|
||||
<?php
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Psr\Log\NullLogger::class => [''],
|
||||
],
|
||||
];
|
||||
EOF,
|
||||
'assertStrategies' => [
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
[LoggerInterface::class, NullLogger::class, ''],
|
||||
|
@ -128,16 +148,20 @@ EOF,
|
|||
/**
|
||||
* @dataProvider dataHooks
|
||||
*/
|
||||
public function testSetupHooks(string $content, array $addonsArray, array $assertStrategies)
|
||||
public function testSetupHooks(string $content, string $addonContent, array $assertStrategies)
|
||||
{
|
||||
vfsStream::newFile(StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php')
|
||||
->withContent($content)
|
||||
->at($this->root);
|
||||
|
||||
$addonLoader = \Mockery::mock(ICanLoadAddons::class);
|
||||
$addonLoader->shouldReceive('getActiveAddonConfig')->andReturn($addonsArray)->once();
|
||||
vfsStream::newFile('addon/testaddon/' . StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php')
|
||||
->withContent($addonContent)
|
||||
->at($this->root);
|
||||
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $addonLoader);
|
||||
$config = \Mockery::mock(IManageConfigValues::class);
|
||||
$config->shouldReceive('get')->andReturn(['testaddon' => ['admin' => false]])->once();
|
||||
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $config);
|
||||
|
||||
$instanceManager = \Mockery::mock(ICanRegisterStrategies::class);
|
||||
foreach ($assertStrategies as $assertStrategy) {
|
||||
|
@ -155,13 +179,15 @@ EOF,
|
|||
*/
|
||||
public function testMissingStrategiesFile()
|
||||
{
|
||||
$addonLoader = \Mockery::mock(ICanLoadAddons::class);
|
||||
$config = \Mockery::mock(IManageConfigValues::class);
|
||||
$instanceManager = \Mockery::mock(ICanRegisterStrategies::class);
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $addonLoader);
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $config);
|
||||
|
||||
self::expectException(HookConfigException::class);
|
||||
self::expectExceptionMessage(sprintf('config file %s does not exist.',
|
||||
$this->root->url() . '/' . StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php'));
|
||||
self::expectExceptionMessage(sprintf(
|
||||
'config file %s does not exist.',
|
||||
$this->root->url() . '/' . StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php'
|
||||
));
|
||||
|
||||
$hookFileManager->loadConfig();
|
||||
}
|
||||
|
@ -171,17 +197,19 @@ EOF,
|
|||
*/
|
||||
public function testWrongStrategiesFile()
|
||||
{
|
||||
$addonLoader = \Mockery::mock(ICanLoadAddons::class);
|
||||
$config = \Mockery::mock(IManageConfigValues::class);
|
||||
$instanceManager = \Mockery::mock(ICanRegisterStrategies::class);
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $addonLoader);
|
||||
$hookFileManager = new StrategiesFileManager($this->root->url(), $config);
|
||||
|
||||
vfsStream::newFile(StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php')
|
||||
->withContent("<?php return 'WRONG_CONTENT';")
|
||||
->at($this->root);
|
||||
|
||||
self::expectException(HookConfigException::class);
|
||||
self::expectExceptionMessage(sprintf('Error loading config file %s.',
|
||||
$this->root->url() . '/' . StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php'));
|
||||
self::expectExceptionMessage(sprintf(
|
||||
'Error loading config file %s.',
|
||||
$this->root->url() . '/' . StrategiesFileManager::STATIC_DIR . '/' . StrategiesFileManager::CONFIG_NAME . '.config.php'
|
||||
));
|
||||
|
||||
$hookFileManager->loadConfig();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue