2015-06-11 04:47:51 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2015-06-11 04:47:51 -04:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-06-11 04:47:51 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test;
|
2020-04-09 05:48:10 -04:00
|
|
|
|
2016-10-31 06:07:54 -04:00
|
|
|
use OC\App\AppStore\Fetcher\AppFetcher;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OC\Config;
|
|
|
|
|
use OC\Server;
|
2023-08-29 18:30:52 -04:00
|
|
|
use OCP\Comments\ICommentsManager;
|
2026-03-09 11:35:12 -04:00
|
|
|
use OCP\IConfig;
|
2015-06-11 04:47:51 -04:00
|
|
|
|
2015-11-20 05:27:11 -05:00
|
|
|
/**
|
|
|
|
|
* Class Server
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @package Test
|
|
|
|
|
*/
|
2025-10-20 19:52:40 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
2016-05-20 09:38:20 -04:00
|
|
|
class ServerTest extends \Test\TestCase {
|
2025-06-30 10:56:59 -04:00
|
|
|
/** @var Server */
|
2015-06-11 04:47:51 -04:00
|
|
|
protected $server;
|
|
|
|
|
|
|
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2015-06-11 04:47:51 -04:00
|
|
|
parent::setUp();
|
2025-06-12 12:31:58 -04:00
|
|
|
$config = new Config(\OC::$configDir);
|
|
|
|
|
$this->server = new Server('', $config);
|
2015-06-11 04:47:51 -04:00
|
|
|
}
|
|
|
|
|
|
2025-05-13 04:10:13 -04:00
|
|
|
public static function dataTestQuery(): array {
|
2015-06-11 04:47:51 -04:00
|
|
|
return [
|
2024-09-17 11:48:01 -04:00
|
|
|
['\OCP\Activity\IManager', '\OC\Activity\Manager'],
|
|
|
|
|
['\OCP\IConfig', '\OC\AllConfig'],
|
|
|
|
|
['\OCP\IAppConfig', '\OC\AppConfig'],
|
|
|
|
|
[AppFetcher::class, AppFetcher::class],
|
|
|
|
|
['\OCP\App\IAppManager', '\OC\App\AppManager'],
|
|
|
|
|
['\OCP\Command\IBus', '\OC\Command\AsyncBus'],
|
|
|
|
|
['\OCP\IAvatarManager', '\OC\Avatar\AvatarManager'],
|
2015-06-11 04:47:51 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param string $serviceName
|
|
|
|
|
* @param string $instanceOf
|
|
|
|
|
*/
|
2025-06-30 10:56:59 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('dataTestQuery')]
|
2026-03-09 11:35:12 -04:00
|
|
|
public function testQuery(string $serviceName, string $instanceOf): void {
|
2015-06-11 05:29:45 -04:00
|
|
|
$this->assertInstanceOf($instanceOf, $this->server->query($serviceName), 'Service "' . $serviceName . '"" did not return the right class');
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-03 15:53:58 -05:00
|
|
|
public function testOverwriteDefaultCommentsManager(): void {
|
2026-03-09 11:35:12 -04:00
|
|
|
$config = $this->server->get(IConfig::class);
|
2015-12-03 15:53:58 -05:00
|
|
|
$defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
|
|
|
|
|
|
|
|
|
|
$config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');
|
|
|
|
|
|
2023-08-29 18:30:52 -04:00
|
|
|
$manager = $this->server->get(ICommentsManager::class);
|
2015-12-03 15:53:58 -05:00
|
|
|
$this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager);
|
|
|
|
|
|
|
|
|
|
$config->setSystemValue('comments.managerFactory', $defaultManagerFactory);
|
|
|
|
|
}
|
2015-06-11 04:47:51 -04:00
|
|
|
}
|