2016-10-07 08:25:18 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2016-10-07 08:25:18 -04:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-10-07 08:25:18 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test;
|
|
|
|
|
|
2023-05-31 15:15:51 -04:00
|
|
|
use OCP\App\IAppManager;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OCP\AppFramework\App;
|
2024-09-12 10:17:19 -04:00
|
|
|
use OCP\Server;
|
2023-05-31 15:15:51 -04:00
|
|
|
|
2016-10-07 08:25:18 -04:00
|
|
|
/**
|
|
|
|
|
* Class InfoXmlTest
|
|
|
|
|
*
|
|
|
|
|
* @group DB
|
|
|
|
|
* @package Test
|
|
|
|
|
*/
|
|
|
|
|
class InfoXmlTest extends TestCase {
|
2024-09-12 10:17:19 -04:00
|
|
|
private IAppManager $appManager;
|
|
|
|
|
|
|
|
|
|
protected function setUp(): void {
|
|
|
|
|
parent::setUp();
|
|
|
|
|
$this->appManager = Server::get(IAppManager::class);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-13 04:10:13 -04:00
|
|
|
public static function dataApps(): array {
|
2016-10-07 08:25:18 -04:00
|
|
|
return [
|
|
|
|
|
['admin_audit'],
|
|
|
|
|
['comments'],
|
|
|
|
|
['dav'],
|
|
|
|
|
['encryption'],
|
|
|
|
|
['federatedfilesharing'],
|
|
|
|
|
['federation'],
|
|
|
|
|
['files'],
|
|
|
|
|
['files_external'],
|
|
|
|
|
['files_sharing'],
|
|
|
|
|
['files_trashbin'],
|
|
|
|
|
['files_versions'],
|
|
|
|
|
['provisioning_api'],
|
|
|
|
|
['systemtags'],
|
|
|
|
|
['theming'],
|
2019-09-17 10:33:27 -04:00
|
|
|
['settings'],
|
2016-10-07 08:25:18 -04:00
|
|
|
['twofactor_backupcodes'],
|
|
|
|
|
['updatenotification'],
|
|
|
|
|
['user_ldap'],
|
|
|
|
|
['workflowengine'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $app
|
|
|
|
|
*/
|
2025-06-30 10:56:59 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('dataApps')]
|
2016-10-07 08:25:18 -04:00
|
|
|
public function testClasses($app): void {
|
2024-09-12 10:17:19 -04:00
|
|
|
$appInfo = $this->appManager->getAppInfo($app);
|
|
|
|
|
$appPath = $this->appManager->getAppPath($app);
|
2016-10-07 08:25:18 -04:00
|
|
|
\OC_App::registerAutoloading($app, $appPath);
|
|
|
|
|
|
2017-03-22 06:24:16 -04:00
|
|
|
//Add the appcontainer
|
2025-06-12 12:31:58 -04:00
|
|
|
$applicationClassName = App::buildAppNamespace($app) . '\\AppInfo\\Application';
|
2017-03-22 06:24:16 -04:00
|
|
|
if (class_exists($applicationClassName)) {
|
|
|
|
|
$application = new $applicationClassName();
|
2018-01-25 05:23:12 -05:00
|
|
|
$this->addToAssertionCount(1);
|
2017-03-22 06:24:16 -04:00
|
|
|
} else {
|
2025-06-12 12:31:58 -04:00
|
|
|
$application = new App($app);
|
2018-01-25 05:23:12 -05:00
|
|
|
$this->addToAssertionCount(1);
|
2017-03-22 06:24:16 -04:00
|
|
|
}
|
|
|
|
|
|
2016-10-07 08:25:18 -04:00
|
|
|
if (isset($appInfo['background-jobs'])) {
|
|
|
|
|
foreach ($appInfo['background-jobs'] as $job) {
|
|
|
|
|
$this->assertTrue(class_exists($job), 'Asserting background job "' . $job . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($job, Server::get($job));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['two-factor-providers'])) {
|
|
|
|
|
foreach ($appInfo['two-factor-providers'] as $provider) {
|
|
|
|
|
$this->assertTrue(class_exists($provider), 'Asserting two-factor providers "' . $provider . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($provider, Server::get($provider));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['commands'])) {
|
|
|
|
|
foreach ($appInfo['commands'] as $command) {
|
|
|
|
|
$this->assertTrue(class_exists($command), 'Asserting command "' . $command . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($command, Server::get($command));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['repair-steps']['pre-migration'])) {
|
|
|
|
|
foreach ($appInfo['repair-steps']['pre-migration'] as $migration) {
|
|
|
|
|
$this->assertTrue(class_exists($migration), 'Asserting pre-migration "' . $migration . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($migration, Server::get($migration));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['repair-steps']['post-migration'])) {
|
|
|
|
|
foreach ($appInfo['repair-steps']['post-migration'] as $migration) {
|
|
|
|
|
$this->assertTrue(class_exists($migration), 'Asserting post-migration "' . $migration . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($migration, Server::get($migration));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['repair-steps']['live-migration'])) {
|
|
|
|
|
foreach ($appInfo['repair-steps']['live-migration'] as $migration) {
|
|
|
|
|
$this->assertTrue(class_exists($migration), 'Asserting live-migration "' . $migration . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($migration, Server::get($migration));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['repair-steps']['install'])) {
|
|
|
|
|
foreach ($appInfo['repair-steps']['install'] as $migration) {
|
|
|
|
|
$this->assertTrue(class_exists($migration), 'Asserting install-migration "' . $migration . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($migration, Server::get($migration));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($appInfo['repair-steps']['uninstall'])) {
|
|
|
|
|
foreach ($appInfo['repair-steps']['uninstall'] as $migration) {
|
|
|
|
|
$this->assertTrue(class_exists($migration), 'Asserting uninstall-migration "' . $migration . '" exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($migration, Server::get($migration));
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
2016-10-11 13:47:59 -04:00
|
|
|
|
|
|
|
|
if (isset($appInfo['commands'])) {
|
|
|
|
|
foreach ($appInfo['commands'] as $command) {
|
|
|
|
|
$this->assertTrue(class_exists($command), 'Asserting command "' . $command . '"exists');
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->assertInstanceOf($command, Server::get($command));
|
2016-10-11 13:47:59 -04:00
|
|
|
}
|
|
|
|
|
}
|
2016-10-07 08:25:18 -04:00
|
|
|
}
|
|
|
|
|
}
|