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.

74 lines
2.0 KiB

10 years ago
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Thomas Müller <thomas.mueller@tmit.eu>
  5. *
  6. * @copyright Copyright (c) 2016, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  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, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  23. use OCA\DAV\Connector\Sabre\MaintenancePlugin;
  24. use Test\TestCase;
  25. use OCP\IConfig;
  26. /**
  27. * Class MaintenancePluginTest
  28. *
  29. * @package OCA\DAV\Tests\unit\Connector\Sabre
  30. */
  31. class MaintenancePluginTest extends TestCase {
  32. /** @var IConfig */
  33. private $config;
  34. /** @var MaintenancePlugin */
  35. private $maintenancePlugin;
  36. public function setUp() {
  37. parent::setUp();
  38. $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
  39. $this->maintenancePlugin = new MaintenancePlugin($this->config);
  40. }
  41. /**
  42. * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
  43. * @expectedExceptionMessage System in single user mode.
  44. */
  45. public function testSingleUserMode() {
  46. $this->config
  47. ->expects($this->once())
  48. ->method('getSystemValue')
  49. ->with('singleuser', false)
  50. ->will($this->returnValue(true));
  51. $this->maintenancePlugin->checkMaintenanceMode();
  52. }
  53. /**
  54. * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
  55. * @expectedExceptionMessage System in single user mode.
  56. */
  57. public function testMaintenanceMode() {
  58. $this->config
  59. ->expects($this->exactly(1))
  60. ->method('getSystemValue')
  61. ->will($this->onConsecutiveCalls([false, true]));
  62. $this->maintenancePlugin->checkMaintenanceMode();
  63. }
  64. }