MaintenancePluginTest.php 2.2 KB

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. * @author Valdnet <47037905+Valdnet@users.noreply.github.com>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  28. use OCA\DAV\Connector\Sabre\MaintenancePlugin;
  29. use OCP\IConfig;
  30. use OCP\IL10N;
  31. use Test\TestCase;
  32. /**
  33. * Class MaintenancePluginTest
  34. *
  35. * @package OCA\DAV\Tests\unit\Connector\Sabre
  36. */
  37. class MaintenancePluginTest extends TestCase {
  38. /** @var IConfig */
  39. private $config;
  40. /** @var \PHPUnit\Framework\MockObject\Builder\InvocationMocker|\PHPUnit_Framework_MockObject_Builder_InvocationMocker|IL10N */
  41. private $l10n;
  42. /** @var MaintenancePlugin */
  43. private $maintenancePlugin;
  44. protected function setUp(): void {
  45. parent::setUp();
  46. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  47. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  48. $this->maintenancePlugin = new MaintenancePlugin($this->config, $this->l10n);
  49. }
  50. public function testMaintenanceMode(): void {
  51. $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
  52. $this->expectExceptionMessage('System is in maintenance mode.');
  53. $this->config
  54. ->expects($this->exactly(1))
  55. ->method('getSystemValueBool')
  56. ->with('maintenance')
  57. ->willReturn(true);
  58. $this->l10n
  59. ->expects($this->any())
  60. ->method('t')
  61. ->willReturnArgument(0);
  62. $this->maintenancePlugin->checkMaintenanceMode();
  63. }
  64. }