aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/Controller/ShareInfoControllerTest.php')
-rw-r--r--apps/files_sharing/tests/Controller/ShareInfoControllerTest.php66
1 files changed, 22 insertions, 44 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
index 882e858217e..1a678610805 100644
--- a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
@@ -1,25 +1,8 @@
<?php
+
/**
- *
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Files_Sharing\Tests\Controller;
@@ -33,42 +16,38 @@ use OCP\IRequest;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
use OCP\Share\IShare;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ShareInfoControllerTest extends TestCase {
- /** @var ShareInfoController */
- private $controller;
-
- /** @var ShareManager|\PHPUnit_Framework_MockObject_MockObject */
- private $shareManager;
+ protected ShareInfoController $controller;
+ protected ShareManager&MockObject $shareManager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(ShareManager::class);
- $this->controller = $this->getMockBuilder(ShareInfoController::class)
- ->setConstructorArgs([
- 'files_sharing',
- $this->createMock(IRequest::class),
- $this->shareManager
- ])
- ->setMethods(['addROWrapper'])
- ->getMock();
+ $this->controller = new ShareInfoController(
+ 'files_sharing',
+ $this->createMock(IRequest::class),
+ $this->shareManager
+ );
}
- public function testNoShare() {
+ public function testNoShare(): void {
$this->shareManager->method('getShareByToken')
->with('token')
->willThrowException(new ShareNotFound());
$expected = new JSONResponse([], Http::STATUS_NOT_FOUND);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token'));
}
- public function testWrongPassword() {
+ public function testWrongPassword(): void {
$share = $this->createMock(IShare::class);
$share->method('getPassword')
->willReturn('sharePass');
@@ -81,10 +60,11 @@ class ShareInfoControllerTest extends TestCase {
->willReturn(false);
$expected = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token', 'pass'));
}
- public function testNoReadPermissions() {
+ public function testNoReadPermissions(): void {
$share = $this->createMock(IShare::class);
$share->method('getPassword')
->willReturn('sharePass');
@@ -99,6 +79,7 @@ class ShareInfoControllerTest extends TestCase {
->willReturn(true);
$expected = new JSONResponse([], Http::STATUS_FORBIDDEN);
+ $expected->throttle(['token' => 'token']);
$this->assertEquals($expected, $this->controller->info('token', 'pass'));
}
@@ -122,7 +103,7 @@ class ShareInfoControllerTest extends TestCase {
return $file;
}
- public function testInfoFile() {
+ public function testInfoFile(): void {
$file = $this->prepareFile();
$share = $this->createMock(IShare::class);
@@ -154,7 +135,7 @@ class ShareInfoControllerTest extends TestCase {
$this->assertEquals($expected, $this->controller->info('token', 'pass'));
}
- public function testInfoFileRO() {
+ public function testInfoFileRO(): void {
$file = $this->prepareFile();
$share = $this->createMock(IShare::class);
@@ -172,9 +153,6 @@ class ShareInfoControllerTest extends TestCase {
->with($share, 'pass')
->willReturn(true);
- $this->controller->expects($this->once())
- ->method('addROWrapper');
-
$expected = new JSONResponse([
'id' => 42,
'parentId' => 41,
@@ -239,7 +217,7 @@ class ShareInfoControllerTest extends TestCase {
return $root;
}
- public function testInfoFolder() {
+ public function testInfoFolder(): void {
$file = $this->prepareFolder();
$share = $this->createMock(IShare::class);
@@ -284,7 +262,7 @@ class ShareInfoControllerTest extends TestCase {
'parentId' => 43,
'mtime' => 1339,
'name' => 'file',
- 'permissions' => 9,
+ 'permissions' => 1,
'mimetype' => 'mime/type',
'size' => 3,
'type' => 'file',