aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php')
-rw-r--r--apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php46
1 files changed, 14 insertions, 32 deletions
diff --git a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php
index a0733a68550..0e82ef0a3ae 100644
--- a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php
+++ b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php
@@ -1,48 +1,30 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\Tests\unit\DAV;
use OCA\DAV\Files\BrowserErrorPagePlugin;
+use PHPUnit\Framework\MockObject\MockObject;
use Sabre\DAV\Exception\NotFound;
use Sabre\HTTP\Response;
class BrowserErrorPagePluginTest extends \Test\TestCase {
- /**
- * @dataProvider providesExceptions
- * @param $expectedCode
- * @param $exception
- */
- public function test($expectedCode, $exception) {
- /** @var BrowserErrorPagePlugin | \PHPUnit\Framework\MockObject\MockObject $plugin */
- $plugin = $this->getMockBuilder(BrowserErrorPagePlugin::class)->setMethods(['sendResponse', 'generateBody'])->getMock();
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesExceptions')]
+ public function test(int $expectedCode, \Throwable $exception): void {
+ /** @var BrowserErrorPagePlugin&MockObject $plugin */
+ $plugin = $this->getMockBuilder(BrowserErrorPagePlugin::class)->onlyMethods(['sendResponse', 'generateBody'])->getMock();
$plugin->expects($this->once())->method('generateBody')->willReturn(':boom:');
$plugin->expects($this->once())->method('sendResponse');
- /** @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject $server */
- $server = $this->getMockBuilder('Sabre\DAV\Server')->disableOriginalConstructor()->getMock();
+ /** @var \Sabre\DAV\Server&MockObject $server */
+ $server = $this->createMock('Sabre\DAV\Server');
$server->expects($this->once())->method('on');
- $httpResponse = $this->getMockBuilder(Response::class)->disableOriginalConstructor()->getMock();
+ $httpResponse = $this->createMock(Response::class);
$httpResponse->expects($this->once())->method('addHeaders');
$httpResponse->expects($this->once())->method('setStatus')->with($expectedCode);
$httpResponse->expects($this->once())->method('setBody')->with(':boom:');
@@ -51,7 +33,7 @@ class BrowserErrorPagePluginTest extends \Test\TestCase {
$plugin->logException($exception);
}
- public function providesExceptions() {
+ public static function providesExceptions(): array {
return [
[ 404, new NotFound()],
[ 500, new \RuntimeException()],