MaintenancePluginTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  25. use OCA\DAV\Connector\Sabre\MaintenancePlugin;
  26. use OCP\IConfig;
  27. use Test\TestCase;
  28. /**
  29. * Class MaintenancePluginTest
  30. *
  31. * @package OCA\DAV\Tests\unit\Connector\Sabre
  32. */
  33. class MaintenancePluginTest extends TestCase {
  34. /** @var IConfig */
  35. private $config;
  36. /** @var MaintenancePlugin */
  37. private $maintenancePlugin;
  38. protected function setUp(): void {
  39. parent::setUp();
  40. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  41. $this->maintenancePlugin = new MaintenancePlugin($this->config);
  42. }
  43. public function testMaintenanceMode() {
  44. $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
  45. $this->expectExceptionMessage('System in maintenance mode.');
  46. $this->config
  47. ->expects($this->exactly(1))
  48. ->method('getSystemValueBool')
  49. ->with('maintenance')
  50. ->will($this->returnValue(true));
  51. $this->maintenancePlugin->checkMaintenanceMode();
  52. }
  53. }