AppsDisableTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. protected function setUp(): void {
  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->assertStringContainsString($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 1.10.0 disabled'],
  59. [['comments'], 0, 'comments 1.10.0 disabled'],
  60. [['invalid_app'], 0, 'No such app enabled: invalid_app'],
  61. [['admin_audit', 'comments'], 0, "admin_audit 1.10.0 disabled\ncomments 1.10.0 disabled"],
  62. [['admin_audit', 'comments', 'invalid_app'], 0, "admin_audit 1.10.0 disabled\ncomments 1.10.0 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 1.10.0 disabled"],
  66. [['provisioning_api', 'comments'], 2, "provisioning_api can't be disabled.\ncomments 1.10.0 disabled"],
  67. ];
  68. }
  69. }