MaintenancePluginTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  8. use OCA\DAV\Connector\Sabre\MaintenancePlugin;
  9. use OCP\IConfig;
  10. use OCP\IL10N;
  11. use Test\TestCase;
  12. /**
  13. * Class MaintenancePluginTest
  14. *
  15. * @package OCA\DAV\Tests\unit\Connector\Sabre
  16. */
  17. class MaintenancePluginTest extends TestCase {
  18. /** @var IConfig */
  19. private $config;
  20. /** @var \PHPUnit\Framework\MockObject\Builder\InvocationMocker|\PHPUnit_Framework_MockObject_Builder_InvocationMocker|IL10N */
  21. private $l10n;
  22. /** @var MaintenancePlugin */
  23. private $maintenancePlugin;
  24. protected function setUp(): void {
  25. parent::setUp();
  26. $this->config = $this->getMockBuilder(IConfig::class)->getMock();
  27. $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
  28. $this->maintenancePlugin = new MaintenancePlugin($this->config, $this->l10n);
  29. }
  30. public function testMaintenanceMode(): void {
  31. $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
  32. $this->expectExceptionMessage('System is in maintenance mode.');
  33. $this->config
  34. ->expects($this->exactly(1))
  35. ->method('getSystemValueBool')
  36. ->with('maintenance')
  37. ->willReturn(true);
  38. $this->l10n
  39. ->expects($this->any())
  40. ->method('t')
  41. ->willReturnArgument(0);
  42. $this->maintenancePlugin->checkMaintenanceMode();
  43. }
  44. }