Replace test addon with vfs files

This commit is contained in:
Art4 2025-05-15 07:14:11 +00:00
parent 367f7bd377
commit 075e9eaaa9
2 changed files with 31 additions and 34 deletions

View file

@ -24,8 +24,22 @@ class AddonManagerHelperTest extends TestCase
{ {
public function testGetAddonInfoReturnsAddonInfo(): void public function testGetAddonInfoReturnsAddonInfo(): void
{ {
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
'helloaddon' => [
'helloaddon.php' => <<<PHP
<?php
/**
* Name: Hello Addon
* Description: For testing purpose only
* Version: 1.0
* Author: Artur Weigandt <dont-mail-me@example.com>
*/
PHP,
]
]);
$addonManagerHelper = new AddonManagerHelper( $addonManagerHelper = new AddonManagerHelper(
__DIR__ . '/../../../Util/addons', $root->url(),
$this->createStub(Database::class), $this->createStub(Database::class),
$this->createStub(IManageConfigValues::class), $this->createStub(IManageConfigValues::class),
$this->createStub(ICanCache::class), $this->createStub(ICanCache::class),
@ -50,8 +64,10 @@ class AddonManagerHelperTest extends TestCase
], ],
]); ]);
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
$addonManagerHelper = new AddonManagerHelper( $addonManagerHelper = new AddonManagerHelper(
__DIR__ . '/../../../Util/addons', $root->url(),
$this->createStub(Database::class), $this->createStub(Database::class),
$config, $config,
$this->createStub(ICanCache::class), $this->createStub(ICanCache::class),
@ -78,8 +94,10 @@ class AddonManagerHelperTest extends TestCase
], ],
]); ]);
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
$addonManagerHelper = new AddonManagerHelper( $addonManagerHelper = new AddonManagerHelper(
__DIR__ . '/../../../Util/addons', $root->url(),
$this->createStub(Database::class), $this->createStub(Database::class),
$config, $config,
$this->createStub(ICanCache::class), $this->createStub(ICanCache::class),
@ -104,8 +122,10 @@ class AddonManagerHelperTest extends TestCase
], ],
]); ]);
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
$addonManagerHelper = new AddonManagerHelper( $addonManagerHelper = new AddonManagerHelper(
__DIR__ . '/../../../Util/addons', $root->url(),
$this->createStub(Database::class), $this->createStub(Database::class),
$config, $config,
$this->createStub(ICanCache::class), $this->createStub(ICanCache::class),
@ -118,8 +138,14 @@ class AddonManagerHelperTest extends TestCase
public function testGetAvailableAddons(): void public function testGetAvailableAddons(): void
{ {
$root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
'helloaddon' => [
'helloaddon.php' => '<?php',
]
]);
$addonManagerHelper = new AddonManagerHelper( $addonManagerHelper = new AddonManagerHelper(
__DIR__ . '/../../../Util/addons', $root->url(),
$this->createStub(Database::class), $this->createStub(Database::class),
$this->createStub(IManageConfigValues::class), $this->createStub(IManageConfigValues::class),
$this->createStub(ICanCache::class), $this->createStub(ICanCache::class),

View file

@ -1,29 +0,0 @@
<?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>';
}