2019-01-27 08:34:39 -05:00
|
|
|
<?php
|
2020-04-09 05:50:14 -04:00
|
|
|
|
2019-01-27 08:47:19 -05:00
|
|
|
declare(strict_types=1);
|
2019-01-27 08:34:39 -05:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-01-27 08:34:39 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Tests\Core\Command\Config;
|
|
|
|
|
|
|
|
|
|
use OC\Core\Command\App\Disable;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OCP\App\IAppManager;
|
|
|
|
|
use OCP\Server;
|
2019-01-27 08:34:39 -05:00
|
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class AppsDisableTest
|
|
|
|
|
*/
|
2025-10-20 19:52:40 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
2019-01-27 08:34:39 -05:00
|
|
|
class AppsDisableTest extends TestCase {
|
|
|
|
|
/** @var CommandTester */
|
|
|
|
|
private $commandTester;
|
|
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2019-01-27 08:34:39 -05:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$command = new Disable(
|
2025-06-12 12:31:58 -04:00
|
|
|
Server::get(IAppManager::class)
|
2019-01-27 08:34:39 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->commandTester = new CommandTester($command);
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
Server::get(IAppManager::class)->enableApp('admin_audit');
|
|
|
|
|
Server::get(IAppManager::class)->enableApp('comments');
|
2019-01-27 08:34:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $appId
|
|
|
|
|
* @param $groups
|
|
|
|
|
* @param $statusCode
|
2021-10-01 16:30:02 -04:00
|
|
|
* @param $pattern
|
2019-01-27 08:34:39 -05:00
|
|
|
*/
|
2025-06-30 10:56:59 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider('dataCommandInput')]
|
2021-10-01 16:30:02 -04:00
|
|
|
public function testCommandInput($appId, $statusCode, $pattern): void {
|
2019-01-27 08:34:39 -05:00
|
|
|
$input = ['app-id' => $appId];
|
|
|
|
|
|
|
|
|
|
$this->commandTester->execute($input);
|
|
|
|
|
|
2022-05-24 07:26:58 -04:00
|
|
|
$this->assertMatchesRegularExpression('/' . $pattern . '/', $this->commandTester->getDisplay());
|
2019-01-27 08:34:39 -05:00
|
|
|
$this->assertSame($statusCode, $this->commandTester->getStatusCode());
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-02 08:00:10 -04:00
|
|
|
public static function dataCommandInput(): array {
|
2019-01-27 08:34:39 -05:00
|
|
|
return [
|
2021-10-01 16:30:02 -04:00
|
|
|
[['admin_audit'], 0, 'admin_audit ([\d\.]*) disabled'],
|
|
|
|
|
[['comments'], 0, 'comments ([\d\.]*) disabled'],
|
2019-01-27 08:34:39 -05:00
|
|
|
[['invalid_app'], 0, 'No such app enabled: invalid_app'],
|
|
|
|
|
|
2021-10-01 16:30:02 -04:00
|
|
|
[['admin_audit', 'comments'], 0, "admin_audit ([\d\.]*) disabled\ncomments ([\d\.]*) disabled"],
|
|
|
|
|
[['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit ([\d\.]*) disabled\ncomments ([\d\.]*) disabled\nNo such app enabled: invalid_app"],
|
2019-01-27 08:34:39 -05:00
|
|
|
|
|
|
|
|
[['files'], 2, "files can't be disabled"],
|
|
|
|
|
[['provisioning_api'], 2, "provisioning_api can't be disabled"],
|
|
|
|
|
|
2021-10-01 16:30:02 -04:00
|
|
|
[['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit ([\d\.]*) disabled"],
|
|
|
|
|
[['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments ([\d\.]*) disabled"],
|
2019-01-27 08:34:39 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|