@@ -258,12 +258,12 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo
258258 // The given password (but not the autogenerated password) should not be
259259 // mailed to the receiver of the share because permanent passwords are not enforced.
260260 $ this ->shareManager ->expects ($ this ->any ())->method ('shareApiLinkEnforcePassword ' )->willReturn (false );
261- $ this ->config ->expects ($ this ->once ())->method ('getSystemValue ' )->with ( ' sharing.enable_mail_link_password_expiration ' )-> willReturn (false );
261+ $ this ->settingsManager ->expects ($ this ->once ())->method ('sendPasswordByMail ' )->willReturn (true );
262262 $ instance ->expects ($ this ->never ())->method ('autoGeneratePassword ' );
263263
264264 // A password is set but no password sent via talk has been requested
265265 $ instance ->expects ($ this ->once ())->method ('sendEmail ' )->with ($ share , ['receiver@example.com ' ]);
266- $ instance ->expects ($ this ->once ())->method ('sendPassword ' )->with ($ share , 'password ' );
266+ $ instance ->expects ($ this ->once ())->method ('sendPassword ' )->with ($ share , 'password ' )-> willReturn ( true ) ;
267267 $ instance ->expects ($ this ->never ())->method ('sendPasswordToOwner ' );
268268
269269 $ this ->assertSame ($ expectedShare , $ instance ->create ($ share ));
@@ -306,66 +306,60 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo
306306 // aside from the main email notification.
307307 $ this ->shareManager ->expects ($ this ->any ())->method ('shareApiLinkEnforcePassword ' )->willReturn (false );
308308 $ instance ->expects ($ this ->never ())->method ('autoGeneratePassword ' );
309- $ this ->config ->expects ($ this ->once ())->method ('getSystemValue ' )
310- ->with ('sharing.enable_mail_link_password_expiration ' )
311- ->willReturn (true );
312309
313310 $ this ->settingsManager ->expects ($ this ->once ())->method ('sendPasswordByMail ' )->willReturn (true );
314311
315312 // No password has been set and no password sent via talk has been requested,
316313 // but password has been enforced for the whole instance and will be generated.
317314 $ instance ->expects ($ this ->once ())->method ('sendEmail ' )->with ($ share , ['receiver@example.com ' ]);
318- $ instance ->expects ($ this ->never ())->method ('sendPassword ' );
315+ $ instance ->expects ($ this ->once ())->method ('sendPassword ' )-> with ( $ share , ' password ' )-> willReturn ( true );
319316 $ instance ->expects ($ this ->never ())->method ('sendPasswordToOwner ' );
320317
321318 $ this ->assertSame ($ expectedShare , $ instance ->create ($ share ));
322319 $ instance ->sendMailNotification ($ share );
323320 }
324321
325-
326322 public function testCreateSendPasswordToOwnerWhenSendPasswordByMailIsDisabled (): void {
327323 $ expectedShare = $ this ->createMock (IShare::class);
328324 $ node = $ this ->getMockBuilder (File::class)->getMock ();
329325 $ node ->method ('getName ' )->willReturn ('filename ' );
330-
326+
331327 $ share = $ this ->getMockBuilder (IShare::class)->getMock ();
332328 $ share ->method ('getSharedWith ' )->willReturn ('receiver@example.com ' );
333329 $ share ->method ('getSendPasswordByTalk ' )->willReturn (false );
334330 $ share ->method ('getSharedBy ' )->willReturn ('owner ' );
335331 $ share ->method ('getNode ' )->willReturn ($ node );
336- $ share ->method ('getId ' )->willReturn (42 );
332+ $ share ->method ('getId ' )->willReturn (' 42 ' );
337333 $ share ->method ('getNote ' )->willReturn ('' );
338334 $ share ->method ('getToken ' )->willReturn ('token ' );
339335 $ share ->method ('getPassword ' )->willReturn ('password ' );
340-
336+
341337 $ this ->mailer ->method ('validateMailAddress ' )->willReturn (true );
342338 $ this ->hasher ->expects ($ this ->once ())->method ('hash ' )->with ('password ' )->willReturn ('passwordHashed ' );
343339 $ share ->expects ($ this ->once ())->method ('setPassword ' )->with ('passwordHashed ' );
344-
340+
345341 $ instance = $ this ->getInstance ([
346342 'getSharedWith ' , 'createMailShare ' , 'getRawShare ' , 'createShareObject ' ,
347343 'createShareActivity ' , 'autoGeneratePassword ' , 'createPasswordSendActivity ' ,
348344 'sendEmail ' , 'sendPassword ' , 'sendPasswordToOwner ' ,
349345 ]);
350-
346+
351347 $ instance ->expects ($ this ->once ())->method ('getSharedWith ' )->willReturn ([]);
352- $ instance ->expects ($ this ->once ())->method ('createMailShare ' )->with ($ share )->willReturn (42 );
348+ $ instance ->expects ($ this ->once ())->method ('createMailShare ' )->with ($ share )->willReturn (' 42 ' );
353349 $ instance ->expects ($ this ->once ())->method ('createShareActivity ' )->with ($ share );
354350 $ instance ->expects ($ this ->once ())->method ('getRawShare ' )->with (42 )->willReturn (['rawShare ' , 'password ' => 'password ' ]);
355351 $ instance ->expects ($ this ->once ())->method ('createShareObject ' )->with (['rawShare ' , 'password ' => 'password ' ])->willReturn ($ expectedShare );
356-
352+
357353 $ this ->shareManager ->method ('shareApiLinkEnforcePassword ' )->willReturn (false );
358- $ this ->config ->expects ($ this ->once ())->method ('getSystemValue ' )->with ('sharing.enable_mail_link_password_expiration ' )->willReturn (true );
359354 $ this ->settingsManager ->expects ($ this ->once ())->method ('sendPasswordByMail ' )->willReturn (false );
360-
361- $ instance ->expects ($ this ->once ())->method ('sendPasswordToOwner ' )->with ($ share );
355+
356+ $ instance ->expects ($ this ->once ())->method ('sendPasswordToOwner ' )->with ($ share, ' password ' );
362357 $ instance ->expects ($ this ->once ())->method ('sendEmail ' )->with ($ share , ['receiver@example.com ' ]);
363358 $ instance ->expects ($ this ->never ())->method ('sendPassword ' );
364-
359+
365360 $ this ->assertSame ($ expectedShare , $ instance ->create ($ share ));
366361 $ instance ->sendMailNotification ($ share );
367362 }
368-
369363
370364 public function testCreateSendPasswordByMailWithEnforcedPasswordProtectionWithPermanentPassword (): void {
371365 $ expectedShare = $ this ->createMock (IShare::class);
@@ -570,7 +564,7 @@ public function testCreateSendPasswordByTalkWithEnforcedPasswordProtectionWithPe
570564 $ instance ->expects ($ this ->once ())->method ('getRawShare ' )->with (42 )->willReturn (['rawShare ' , 'password ' => 'autogeneratedPassword ' ]);
571565 $ instance ->expects ($ this ->once ())->method ('createShareObject ' )->with (['rawShare ' , 'password ' => 'autogeneratedPassword ' ])->willReturn ($ expectedShare );
572566
573- $ share ->expects ($ this ->exactly (4 ))->method ('getPassword ' )->willReturnOnConsecutiveCalls (null , ' autogeneratedPassword ' , 'autogeneratedPassword ' , 'autogeneratedPassword ' );
567+ $ share ->expects ($ this ->exactly (3 ))->method ('getPassword ' )->willReturnOnConsecutiveCalls (null , 'autogeneratedPassword ' , 'autogeneratedPassword ' );
574568 $ this ->hasher ->expects ($ this ->once ())->method ('hash ' )->with ('autogeneratedPassword ' )->willReturn ('autogeneratedPasswordHashed ' );
575569 $ share ->expects ($ this ->once ())->method ('setPassword ' )->with ('autogeneratedPasswordHashed ' );
576570
0 commit comments