AppsDisableTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019, Daniel Kesselberg (mail@danielkesselberg.de)
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace Tests\Core\Command\Config;
  23. use OC\Core\Command\App\Disable;
  24. use Symfony\Component\Console\Tester\CommandTester;
  25. use Test\TestCase;
  26. /**
  27. * Class AppsDisableTest
  28. *
  29. * @group DB
  30. */
  31. class AppsDisableTest extends TestCase {
  32. /** @var CommandTester */
  33. private $commandTester;
  34. public function setUp() {
  35. parent::setUp();
  36. $command = new Disable(
  37. \OC::$server->getAppManager()
  38. );
  39. $this->commandTester = new CommandTester($command);
  40. \OC::$server->getAppManager()->enableApp('admin_audit');
  41. \OC::$server->getAppManager()->enableApp('comments');
  42. }
  43. /**
  44. * @dataProvider dataCommandInput
  45. * @param $appId
  46. * @param $groups
  47. * @param $statusCode
  48. * @param $output
  49. */
  50. public function testCommandInput($appId, $statusCode, $output): void {
  51. $input = ['app-id' => $appId];
  52. $this->commandTester->execute($input);
  53. $this->assertContains($output, $this->commandTester->getDisplay());
  54. $this->assertSame($statusCode, $this->commandTester->getStatusCode());
  55. }
  56. public function dataCommandInput(): array {
  57. return [
  58. [['admin_audit'], 0, 'admin_audit disabled'],
  59. [['comments'], 0, 'comments disabled'],
  60. [['invalid_app'], 0, 'No such app enabled: invalid_app'],
  61. [['admin_audit', 'comments'], 0, "admin_audit disabled\ncomments disabled"],
  62. [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit disabled\ncomments disabled\nNo such app enabled: invalid_app"],
  63. [['files'], 2, "files can't be disabled"],
  64. [['provisioning_api'], 2, "provisioning_api can't be disabled"],
  65. [['files', 'admin_audit'], 2, "files can't be disabled.\nadmin_audit disabled"],
  66. [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments disabled"],
  67. ];
  68. }
  69. }