From 0e253fb22d3baad8d82ca93fd863a5a1cc684817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 20 May 2025 09:52:07 +0200 Subject: [PATCH 1/3] chore(tests): Cleanup bootstrap.php to be forward-compatible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/bootstrap.php | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 97a11800e..b0808ea8c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,45 +1,32 @@ - * @author Jörn Friedrich Dreyer - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ + +use OCP\App\IAppManager; +use OCP\Server; +use PHPUnit\Framework\TestCase; + if (!defined('PHPUNIT_RUN')) { define('PHPUNIT_RUN', 1); } require_once __DIR__ . '/../../../lib/base.php'; +require_once __DIR__ . '/../../../tests/autoload.php'; -// Fix for "Autoload path not allowed: .../tests/lib/testcase.php" -\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); - -// Fix for "Autoload path not allowed: .../activity/tests/testcase.php" -\OC_App::loadApp('activity'); +Server::get(IAppManager::class)->loadApp('activity'); // Fix for "Autoload path not allowed: .../files/lib/activity.php" -\OC_App::loadApp('files'); +Server::get(IAppManager::class)->loadApp('files'); // Fix for "Autoload path not allowed: .../files_sharing/lib/activity.php" -\OC_App::loadApp('files_sharing'); +Server::get(IAppManager::class)->loadApp('files_sharing'); -if (!class_exists('\PHPUnit\Framework\TestCase')) { +if (!class_exists(TestCase::class)) { require_once('PHPUnit/Autoload.php'); } From 2e584c10adcaa5da4571e285c5051fe030b32ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 20 May 2025 09:52:38 +0200 Subject: [PATCH 2/3] chore(tests): Do not clear hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/bootstrap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b0808ea8c..4957bd037 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -29,5 +29,3 @@ if (!class_exists(TestCase::class)) { require_once('PHPUnit/Autoload.php'); } - -OC_Hook::clear(); From d11a693164331f1e222a77062d040ba8812a4a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 20 May 2025 09:52:55 +0200 Subject: [PATCH 3/3] chore(tests): Remove unusual manual app loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/bootstrap.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4957bd037..633ce34ba 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -20,12 +20,6 @@ Server::get(IAppManager::class)->loadApp('activity'); -// Fix for "Autoload path not allowed: .../files/lib/activity.php" -Server::get(IAppManager::class)->loadApp('files'); - -// Fix for "Autoload path not allowed: .../files_sharing/lib/activity.php" -Server::get(IAppManager::class)->loadApp('files_sharing'); - if (!class_exists(TestCase::class)) { require_once('PHPUnit/Autoload.php'); }