mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 08:14:25 +02:00
Implement getAddonDependencyConfig
This commit is contained in:
parent
638496e553
commit
694893e2bb
3 changed files with 113 additions and 0 deletions
|
@ -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\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Database\Database;
|
||||
|
@ -54,6 +55,76 @@ class AddonManagerHelperTest extends TestCase
|
|||
$this->assertEquals('Hello Addon', $info->getName());
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue