Skip to content

Commit 7d66dcd

Browse files
committed
chore: Adapt tests to getUserFolder return type change
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 1973e7a commit 7d66dcd

File tree

23 files changed

+182
-154
lines changed

23 files changed

+182
-154
lines changed

apps/comments/tests/Unit/Activity/ListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
use OCP\Files\Config\ICachedMountFileInfo;
1818
use OCP\Files\Config\IMountProviderCollection;
1919
use OCP\Files\Config\IUserMountCache;
20-
use OCP\Files\Folder;
2120
use OCP\Files\IRootFolder;
21+
use OCP\Files\IUserFolder;
2222
use OCP\Files\Node;
2323
use OCP\IUser;
2424
use OCP\IUserSession;
@@ -94,7 +94,7 @@ public function testCommentEvent(): void {
9494
$node = $this->createMock(Node::class);
9595
$nodes = [ $node ];
9696

97-
$ownerFolder = $this->createMock(Folder::class);
97+
$ownerFolder = $this->createMock(IUserFolder::class);
9898
$ownerFolder->expects($this->any())
9999
->method('getById')
100100
->willReturn($nodes);

apps/comments/tests/Unit/Controller/NotificationsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use OCP\Comments\IComment;
1616
use OCP\Comments\ICommentsManager;
1717
use OCP\Comments\NotFoundException;
18-
use OCP\Files\Folder;
1918
use OCP\Files\IRootFolder;
19+
use OCP\Files\IUserFolder;
2020
use OCP\Files\Node;
2121
use OCP\IRequest;
2222
use OCP\IURLGenerator;
@@ -99,7 +99,7 @@ public function testViewSuccess(): void {
9999
->willReturn($comment);
100100

101101
$file = $this->createMock(Node::class);
102-
$folder = $this->createMock(Folder::class);
102+
$folder = $this->createMock(IUserFolder::class);
103103
$user = $this->createMock(IUser::class);
104104

105105
$this->rootFolder->expects($this->once())
@@ -176,7 +176,7 @@ public function testViewNoFile(): void {
176176
->with('42')
177177
->willReturn($comment);
178178

179-
$folder = $this->createMock(Folder::class);
179+
$folder = $this->createMock(IUserFolder::class);
180180

181181
$this->rootFolder->expects($this->once())
182182
->method('getUserFolder')

apps/comments/tests/Unit/Notification/NotifierTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use OCP\Comments\IComment;
1313
use OCP\Comments\ICommentsManager;
1414
use OCP\Comments\NotFoundException;
15-
use OCP\Files\Folder;
1615
use OCP\Files\IRootFolder;
16+
use OCP\Files\IUserFolder;
1717
use OCP\Files\Node;
1818
use OCP\IL10N;
1919
use OCP\IURLGenerator;
@@ -80,7 +80,7 @@ public function testPrepareSuccess(): void {
8080
->method('getPath')
8181
->willReturn('/you/files/' . $fileName);
8282

83-
$userFolder = $this->createMock(Folder::class);
83+
$userFolder = $this->createMock(IUserFolder::class);
8484
$this->folder->expects($this->once())
8585
->method('getUserFolder')
8686
->with('you')
@@ -196,7 +196,7 @@ public function testPrepareSuccessDeletedUser(): void {
196196
->method('getPath')
197197
->willReturn('/you/files/' . $fileName);
198198

199-
$userFolder = $this->createMock(Folder::class);
199+
$userFolder = $this->createMock(IUserFolder::class);
200200
$this->folder->expects($this->once())
201201
->method('getUserFolder')
202202
->with('you')
@@ -491,7 +491,7 @@ public function testPrepareUnresolvableFileID(): void {
491491

492492
$displayName = 'Huraga';
493493

494-
$userFolder = $this->createMock(Folder::class);
494+
$userFolder = $this->createMock(IUserFolder::class);
495495
$this->folder->expects($this->once())
496496
->method('getUserFolder')
497497
->with('you')

apps/dav/tests/unit/Controller/DirectControllerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use OCP\Files\File;
2020
use OCP\Files\Folder;
2121
use OCP\Files\IRootFolder;
22+
use OCP\Files\IUserFolder;
2223
use OCP\IRequest;
2324
use OCP\IURLGenerator;
2425
use OCP\Security\ISecureRandom;
@@ -59,7 +60,7 @@ protected function setUp(): void {
5960
}
6061

6162
public function testGetUrlNonExistingFileId(): void {
62-
$userFolder = $this->createMock(Folder::class);
63+
$userFolder = $this->createMock(IUserFolder::class);
6364
$this->rootFolder->method('getUserFolder')
6465
->with('awesomeUser')
6566
->willReturn($userFolder);
@@ -73,7 +74,7 @@ public function testGetUrlNonExistingFileId(): void {
7374
}
7475

7576
public function testGetUrlForFolder(): void {
76-
$userFolder = $this->createMock(Folder::class);
77+
$userFolder = $this->createMock(IUserFolder::class);
7778
$this->rootFolder->method('getUserFolder')
7879
->with('awesomeUser')
7980
->willReturn($userFolder);
@@ -89,7 +90,7 @@ public function testGetUrlForFolder(): void {
8990
}
9091

9192
public function testGetUrlValid(): void {
92-
$userFolder = $this->createMock(Folder::class);
93+
$userFolder = $this->createMock(IUserFolder::class);
9394
$this->rootFolder->method('getUserFolder')
9495
->with('awesomeUser')
9596
->willReturn($userFolder);

apps/dav/tests/unit/Direct/DirectFileTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
use OCA\DAV\Direct\DirectFile;
1313
use OCP\EventDispatcher\IEventDispatcher;
1414
use OCP\Files\File;
15-
use OCP\Files\Folder;
1615
use OCP\Files\IRootFolder;
16+
use OCP\Files\IUserFolder;
1717
use PHPUnit\Framework\MockObject\MockObject;
1818
use Sabre\DAV\Exception\Forbidden;
1919
use Test\TestCase;
2020

2121
class DirectFileTest extends TestCase {
2222
private Direct $direct;
2323
private IRootFolder&MockObject $rootFolder;
24-
private Folder&MockObject $userFolder;
24+
private IUserFolder&MockObject $userFolder;
2525
private File&MockObject $file;
2626
private IEventDispatcher&MockObject $eventDispatcher;
2727
private DirectFile $directFile;
@@ -37,7 +37,7 @@ protected function setUp(): void {
3737

3838
$this->rootFolder = $this->createMock(IRootFolder::class);
3939

40-
$this->userFolder = $this->createMock(Folder::class);
40+
$this->userFolder = $this->createMock(IUserFolder::class);
4141
$this->rootFolder->method('getUserFolder')
4242
->with('directUser')
4343
->willReturn($this->userFolder);

apps/files/tests/Controller/ConversionApiControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use OCP\AppFramework\OCS\OCSNotFoundException;
1515
use OCP\Files\Conversion\IConversionManager;
1616
use OCP\Files\File;
17-
use OCP\Files\Folder;
1817
use OCP\Files\IRootFolder;
18+
use OCP\Files\IUserFolder;
1919
use OCP\IL10N;
2020
use OCP\IRequest;
2121
use PHPUnit\Framework\MockObject\MockObject;
@@ -33,7 +33,7 @@ class ConversionApiControllerTest extends TestCase {
3333
private IConversionManager&MockObject $fileConversionManager;
3434
private IRootFolder&MockObject $rootFolder;
3535
private File&MockObject $file;
36-
private Folder&MockObject $userFolder;
36+
private IUserFolder&MockObject $userFolder;
3737
private IL10N&MockObject $l10n;
3838
private string $user;
3939

@@ -46,7 +46,7 @@ protected function setUp(): void {
4646
$this->l10n = $this->createMock(IL10N::class);
4747
$this->user = 'userid';
4848

49-
$this->userFolder = $this->createMock(Folder::class);
49+
$this->userFolder = $this->createMock(IUserFolder::class);
5050

5151
$this->rootFolder = $this->createMock(IRootFolder::class);
5252
$this->rootFolder->method('getUserFolder')->with($this->user)->willReturn($this->userFolder);

apps/files/tests/Controller/ViewControllerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use OCP\Files\File;
2626
use OCP\Files\Folder;
2727
use OCP\Files\IRootFolder;
28+
use OCP\Files\IUserFolder;
2829
use OCP\Files\Template\ITemplateManager;
2930
use OCP\ICacheFactory;
3031
use OCP\IConfig;
@@ -173,7 +174,7 @@ public function testIndexWithRegularBrowser(): void {
173174
[$this->user->getUID(), 'files', 'show_grid', true],
174175
]);
175176

176-
$baseFolderFiles = $this->getMockBuilder(Folder::class)->getMock();
177+
$baseFolderFiles = $this->getMockBuilder(IUserFolder::class)->getMock();
177178

178179
$this->rootFolder->expects($this->any())
179180
->method('getUserFolder')
@@ -221,7 +222,7 @@ public function testShortRedirect(?string $openfile, ?string $opendetails, strin
221222
->with('files')
222223
->willReturn(true);
223224

224-
$baseFolderFiles = $this->getMockBuilder(Folder::class)->getMock();
225+
$baseFolderFiles = $this->getMockBuilder(IUserFolder::class)->getMock();
225226
$this->rootFolder->expects($this->any())
226227
->method('getUserFolder')
227228
->with('testuser1')
@@ -256,7 +257,7 @@ public function testShowFileRouteWithTrashedFile(): void {
256257
->method('getPath')
257258
->willReturn('testuser1/files_trashbin/files/test.d1462861890/sub');
258259

259-
$baseFolderFiles = $this->createMock(Folder::class);
260+
$baseFolderFiles = $this->createMock(IUserFolder::class);
260261
$baseFolderTrash = $this->createMock(Folder::class);
261262

262263
$this->rootFolder->expects($this->any())

apps/files_sharing/tests/ApplicationTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\Files\File;
1919
use OCP\Files\Folder;
2020
use OCP\Files\IRootFolder;
21+
use OCP\Files\IUserFolder;
2122
use OCP\Files\Storage\IStorage;
2223
use OCP\IUser;
2324
use OCP\IUserSession;
@@ -78,7 +79,7 @@ public function testCheckDirectCanBeDownloaded(
7879
$file = $this->createMock(File::class);
7980
$file->method('getStorage')->willReturn($fileStorage);
8081

81-
$userFolder = $this->createMock(Folder::class);
82+
$userFolder = $this->createMock(IUserFolder::class);
8283
$userFolder->method('get')->willReturn($file);
8384

8485
$user = $this->createMock(IUser::class);
@@ -166,7 +167,7 @@ function (string $fileStorage) use ($nonSharedStorage, $secureSharedStorage) {
166167
$rootFolder->method('getStorage')->willReturn($nonSharedStorage);
167168
$rootFolder->method('getDirectoryListing')->willReturn([$folder]);
168169

169-
$userFolder = $this->createMock(Folder::class);
170+
$userFolder = $this->createMock(IUserFolder::class);
170171
$userFolder->method('get')->willReturn($rootFolder);
171172

172173
$user = $this->createMock(IUser::class);

apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
namespace OCA\Files_Sharing\Tests\Collaboration;
88

99
use OCA\Files_Sharing\Collaboration\ShareRecipientSorter;
10-
use OCP\Files\Folder;
1110
use OCP\Files\IRootFolder;
11+
use OCP\Files\IUserFolder;
1212
use OCP\Files\Node;
1313
use OCP\IUser;
1414
use OCP\IUserSession;
@@ -42,8 +42,7 @@ protected function setUp(): void {
4242
public function testSort($data): void {
4343
$node = $this->createMock(Node::class);
4444

45-
/** @var Folder|\PHPUnit\Framework\MockObject\MockObject $folder */
46-
$folder = $this->createMock(Folder::class);
45+
$folder = $this->createMock(IUserFolder::class);
4746
$this->rootFolder->expects($this->any())
4847
->method('getUserFolder')
4948
->willReturn($folder);
@@ -81,8 +80,7 @@ public function testSort($data): void {
8180
}
8281

8382
public function testSortNoNodes(): void {
84-
/** @var Folder|\PHPUnit\Framework\MockObject\MockObject $folder */
85-
$folder = $this->createMock(Folder::class);
83+
$folder = $this->createMock(IUserFolder::class);
8684
$this->rootFolder->expects($this->any())
8785
->method('getUserFolder')
8886
->willReturn($folder);

0 commit comments

Comments
 (0)