2015-06-29 08:16:27 -04:00
|
|
|
<?php
|
2024-05-28 06:34:11 -04:00
|
|
|
|
2025-05-27 17:36:08 -04:00
|
|
|
declare(strict_types=1);
|
2015-06-29 08:16:27 -04:00
|
|
|
/**
|
2024-05-28 06:34:11 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-06-29 08:16:27 -04:00
|
|
|
*/
|
2016-05-25 10:04:15 -04:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector\Sabre;
|
2015-06-29 08:16:27 -04:00
|
|
|
|
2015-08-30 13:13:01 -04:00
|
|
|
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
|
2015-06-29 08:16:27 -04:00
|
|
|
use OCP\IConfig;
|
2020-05-06 12:11:54 -04:00
|
|
|
use OCP\IL10N;
|
2025-05-27 17:36:08 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2019-11-22 14:52:10 -05:00
|
|
|
use Test\TestCase;
|
2015-06-29 08:16:27 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class MaintenancePluginTest
|
|
|
|
|
*
|
2016-05-25 10:04:15 -04:00
|
|
|
* @package OCA\DAV\Tests\unit\Connector\Sabre
|
2015-06-29 08:16:27 -04:00
|
|
|
*/
|
|
|
|
|
class MaintenancePluginTest extends TestCase {
|
2025-05-27 17:36:08 -04:00
|
|
|
private IConfig&MockObject $config;
|
|
|
|
|
private IL10N&MockObject $l10n;
|
|
|
|
|
private MaintenancePlugin $maintenancePlugin;
|
2015-06-29 08:16:27 -04:00
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2015-06-29 08:16:27 -04:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2025-05-27 17:36:08 -04:00
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
|
|
|
$this->l10n = $this->createMock(IL10N::class);
|
2020-05-06 12:11:54 -04:00
|
|
|
$this->maintenancePlugin = new MaintenancePlugin($this->config, $this->l10n);
|
2015-06-29 08:16:27 -04:00
|
|
|
}
|
|
|
|
|
|
2020-05-06 12:11:54 -04:00
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testMaintenanceMode(): void {
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
|
2021-05-04 05:38:45 -04:00
|
|
|
$this->expectExceptionMessage('System is in maintenance mode.');
|
2019-11-27 09:27:18 -05:00
|
|
|
|
2015-06-29 08:16:27 -04:00
|
|
|
$this->config
|
|
|
|
|
->expects($this->exactly(1))
|
2019-02-22 02:27:22 -05:00
|
|
|
->method('getSystemValueBool')
|
|
|
|
|
->with('maintenance')
|
2020-03-25 17:21:27 -04:00
|
|
|
->willReturn(true);
|
2020-05-06 12:11:54 -04:00
|
|
|
$this->l10n
|
|
|
|
|
->expects($this->any())
|
|
|
|
|
->method('t')
|
|
|
|
|
->willReturnArgument(0);
|
2015-06-29 08:16:27 -04:00
|
|
|
|
|
|
|
|
$this->maintenancePlugin->checkMaintenanceMode();
|
|
|
|
|
}
|
|
|
|
|
}
|