mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 07:44:27 +02:00
Create AddonManagerHelper
This commit is contained in:
parent
6a058793f0
commit
e2a2cf5d6e
3 changed files with 221 additions and 0 deletions
32
tests/Unit/Core/Addon/AddonManagerHelperTest.php
Normal file
32
tests/Unit/Core/Addon/AddonManagerHelperTest.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?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 Friendica\Core\Addon\AddonManagerHelper;
|
||||
use Friendica\Util\Profiler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AddonManagerHelperTest extends TestCase
|
||||
{
|
||||
public function testGetAddonInfoReturnsAddonInfo(): void
|
||||
{
|
||||
$addonManagerHelper = new AddonManagerHelper(
|
||||
__DIR__ . '/../../../Util/addons',
|
||||
$this->createStub(Profiler::class)
|
||||
);
|
||||
|
||||
$info = $addonManagerHelper->getAddonInfo('helloaddon');
|
||||
|
||||
$this->assertInstanceOf(AddonInfo::class, $info);
|
||||
|
||||
$this->assertEquals('Hello Addon', $info->getName());
|
||||
}
|
||||
}
|
29
tests/Util/addons/helloaddon/helloaddon.php
Normal file
29
tests/Util/addons/helloaddon/helloaddon.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
// SPDX-FileCopyrightText: 2010-2024 the Friendica project
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
/**
|
||||
* Name: Hello Addon
|
||||
* Description: For testing purpose only
|
||||
* Version: 1.0
|
||||
* Author: Artur Weigandt <dont-mail-me@example.com>
|
||||
*/
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
|
||||
function helloaddon_install()
|
||||
{
|
||||
Hook::register('page_end', 'addon/helloaddon/helloaddon.php', 'helloaddon_page_end');
|
||||
}
|
||||
|
||||
function helloaddon_uninstall()
|
||||
{
|
||||
Hook::unregister('page_end', 'addon/helloaddon/helloaddon.php', 'helloaddon_page_end');
|
||||
}
|
||||
|
||||
function helloaddon_page_end(&$html)
|
||||
{
|
||||
$html .= '<p>Hello, World!</p>';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue