nextcloud/apps/files_external/tests/Storage/ConfigurableStorageTrait.php
Côme Chilliet 1f3c1a7e74
fix: Fix PHP warnings about including non-existing config files
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-09-27 13:05:33 +02:00

30 lines
694 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_External\Tests\Storage;
trait ConfigurableStorageTrait {
protected ?array $config = null;
protected function loadConfig(string $path): bool {
$this->config = null;
if (file_exists($path)) {
$this->config = include($path);
}
if (!$this->shouldRunConfig($this->config)) {
$this->markTestSkipped(__CLASS__ . ' Backend not configured');
return false;
}
return true;
}
protected function shouldRunConfig(mixed $config): bool {
return is_array($config) && ($config['run'] ?? false);
}
}