You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MaintenancePluginTest.php 2.2KB

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