]> git.mxchange.org Git - friendica.git/commitdiff
Replace test addon with vfs files
authorArt4 <art4@wlabs.de>
Thu, 15 May 2025 07:14:11 +0000 (07:14 +0000)
committerArt4 <art4@wlabs.de>
Thu, 15 May 2025 07:14:11 +0000 (07:14 +0000)
tests/Unit/Core/Addon/AddonManagerHelperTest.php
tests/Util/addons/helloaddon/helloaddon.php [deleted file]

index 41320361ddd4e5affd653a43e791db94a4abe071..9dbbbdfdd0b699728d329e75e03b83dfe4df6b7f 100644 (file)
@@ -24,8 +24,22 @@ class AddonManagerHelperTest extends TestCase
 {
        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(
-                       __DIR__ . '/../../../Util/addons',
+                       $root->url(),
                        $this->createStub(Database::class),
                        $this->createStub(IManageConfigValues::class),
                        $this->createStub(ICanCache::class),
@@ -50,8 +64,10 @@ class AddonManagerHelperTest extends TestCase
                        ],
                ]);
 
+               $root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
+
                $addonManagerHelper = new AddonManagerHelper(
-                       __DIR__ . '/../../../Util/addons',
+                       $root->url(),
                        $this->createStub(Database::class),
                        $config,
                        $this->createStub(ICanCache::class),
@@ -78,8 +94,10 @@ class AddonManagerHelperTest extends TestCase
                        ],
                ]);
 
+               $root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
+
                $addonManagerHelper = new AddonManagerHelper(
-                       __DIR__ . '/../../../Util/addons',
+                       $root->url(),
                        $this->createStub(Database::class),
                        $config,
                        $this->createStub(ICanCache::class),
@@ -104,8 +122,10 @@ class AddonManagerHelperTest extends TestCase
                        ],
                ]);
 
+               $root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, []);
+
                $addonManagerHelper = new AddonManagerHelper(
-                       __DIR__ . '/../../../Util/addons',
+                       $root->url(),
                        $this->createStub(Database::class),
                        $config,
                        $this->createStub(ICanCache::class),
@@ -118,8 +138,14 @@ class AddonManagerHelperTest extends TestCase
 
        public function testGetAvailableAddons(): void
        {
+               $root = vfsStream::setup(__FUNCTION__ . '_addons', 0777, [
+                       'helloaddon' => [
+                               'helloaddon.php' => '<?php',
+                       ]
+               ]);
+
                $addonManagerHelper = new AddonManagerHelper(
-                       __DIR__ . '/../../../Util/addons',
+                       $root->url(),
                        $this->createStub(Database::class),
                        $this->createStub(IManageConfigValues::class),
                        $this->createStub(ICanCache::class),
diff --git a/tests/Util/addons/helloaddon/helloaddon.php b/tests/Util/addons/helloaddon/helloaddon.php
deleted file mode 100644 (file)
index 679298d..0000000
+++ /dev/null
@@ -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>';
-}