1010use OCA \Forms \Constants ;
1111use OCA \Forms \Db \Form ;
1212use OCA \Forms \Helper \FilePathHelper ;
13+ use OCA \Forms \Tests \Unit \UserFolderMockTrait ;
1314use OCP \Files \Folder ;
1415use OCP \Files \IFilenameValidator ;
1516use OCP \Files \IRootFolder ;
1819use Test \TestCase ;
1920
2021class FilePathHelperTest extends TestCase {
22+ use UserFolderMockTrait;
23+
2124 private FilePathHelper $ filePathHelper ;
2225 private IFilenameValidator |MockObject $ filenameValidator ;
2326 private IRootFolder |MockObject $ rootFolder ;
@@ -86,7 +89,7 @@ public function testGetUploadedFilePathWithoutQuestionName() {
8689 }
8790
8891 public function testGetFormsFolderReturnsFolder () {
89- $ userFolder = $ this ->createMock (Folder::class );
92+ $ userFolder = $ this ->createUserFolderMock ( );
9093 $ formsFolder = $ this ->createMock (Folder::class);
9194
9295 $ this ->rootFolder ->expects ($ this ->once ())
@@ -104,7 +107,7 @@ public function testGetFormsFolderReturnsFolder() {
104107 }
105108
106109 public function testGetFormsFolderReturnsNullWhenNotFound () {
107- $ userFolder = $ this ->createMock (Folder::class );
110+ $ userFolder = $ this ->createUserFolderMock ( );
108111
109112 $ this ->rootFolder ->expects ($ this ->once ())
110113 ->method ('getUserFolder ' )
@@ -121,7 +124,7 @@ public function testGetFormsFolderReturnsNullWhenNotFound() {
121124 }
122125
123126 public function testGetFormsFolderReturnsNullWhenNotFolder () {
124- $ userFolder = $ this ->createMock (Folder::class );
127+ $ userFolder = $ this ->createUserFolderMock ( );
125128 $ notAFolder = $ this ->createMock (\OCP \Files \File::class);
126129
127130 $ this ->rootFolder ->expects ($ this ->once ())
@@ -155,7 +158,7 @@ public function testGetAllFormFoldersById() {
155158 ]);
156159
157160 // Mock getFormsFolder to return our formsFolder
158- $ userFolder = $ this ->createMock (Folder::class );
161+ $ userFolder = $ this ->createUserFolderMock ( );
159162 $ this ->rootFolder ->expects ($ this ->once ())
160163 ->method ('getUserFolder ' )
161164 ->with ('user1 ' )
@@ -174,7 +177,7 @@ public function testGetAllFormFoldersById() {
174177 }
175178
176179 public function testGetAllFormFoldersByIdReturnsEmptyWhenFormsFolderNull () {
177- $ userFolder = $ this ->createMock (Folder::class );
180+ $ userFolder = $ this ->createUserFolderMock ( );
178181 $ this ->rootFolder ->expects ($ this ->once ())
179182 ->method ('getUserFolder ' )
180183 ->with ('user1 ' )
@@ -201,7 +204,7 @@ public function testGetSubmissionFolder() {
201204 $ formFolder ->method ('getName ' )->willReturn ('42 - Form Title ' );
202205 $ formsFolder ->method ('getDirectoryListing ' )->willReturn ([$ formFolder ]);
203206
204- $ userFolder = $ this ->createMock (Folder::class );
207+ $ userFolder = $ this ->createUserFolderMock ( );
205208 $ this ->rootFolder ->expects ($ this ->once ())
206209 ->method ('getUserFolder ' )
207210 ->with ('user1 ' )
@@ -232,7 +235,7 @@ public function testGetSubmissionFolderReturnsNullWhenNotFound() {
232235 $ formFolder ->method ('getName ' )->willReturn ('42 - Form Title ' );
233236 $ formsFolder ->method ('getDirectoryListing ' )->willReturn ([$ formFolder ]);
234237
235- $ userFolder = $ this ->createMock (Folder::class );
238+ $ userFolder = $ this ->createUserFolderMock ( );
236239 $ this ->rootFolder ->expects ($ this ->once ())
237240 ->method ('getUserFolder ' )
238241 ->with ('user1 ' )
@@ -264,7 +267,7 @@ public function testGetSubmissionFolderReturnsNullWhenNotFolder() {
264267 $ formFolder ->method ('getName ' )->willReturn ('42 - Form Title ' );
265268 $ formsFolder ->method ('getDirectoryListing ' )->willReturn ([$ formFolder ]);
266269
267- $ userFolder = $ this ->createMock (Folder::class );
270+ $ userFolder = $ this ->createUserFolderMock ( );
268271 $ this ->rootFolder ->expects ($ this ->once ())
269272 ->method ('getUserFolder ' )
270273 ->with ('user1 ' )
0 commit comments