-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40182 from nextcloud/feat/share-by-mail/remove-il…
…ogger-2
- Loading branch information
Showing
1 changed file
with
24 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,6 +198,8 @@ protected function tearDown(): void { | |
} | ||
|
||
public function testCreate() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('user1'); | ||
|
||
|
@@ -210,13 +212,13 @@ public function testCreate() { | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$instance->expects($this->any())->method('sendPassword')->willReturn(true); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
$this->shareManager->expects($this->any())->method('shareApiLinkEnforcePassword')->willReturn(false); | ||
$this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
public function testCreateSendPasswordByMailWithoutEnforcedPasswordProtection() { | ||
|
@@ -250,6 +252,8 @@ public function testCreateSendPasswordByMailWithoutEnforcedPasswordProtection() | |
} | ||
|
||
public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtectionWithPermanentPassword() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('[email protected]'); | ||
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false); | ||
|
@@ -264,7 +268,7 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
|
||
$share->expects($this->once())->method('getPassword')->willReturn('password'); | ||
|
@@ -277,10 +281,12 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo | |
$this->config->expects($this->once())->method('getSystemValue')->with('sharing.enable_mail_link_password_expiration')->willReturn(false); | ||
$instance->expects($this->never())->method('autoGeneratePassword'); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswordProtectionWithoutPermanentPassword() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('[email protected]'); | ||
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false); | ||
|
@@ -295,7 +301,7 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
|
||
$share->expects($this->once())->method('getPassword')->willReturn('password'); | ||
|
@@ -316,10 +322,12 @@ public function testCreateSendPasswordByMailWithPasswordAndWithoutEnforcedPasswo | |
3600 | ||
); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
public function testCreateSendPasswordByMailWithEnforcedPasswordProtectionWithPermanentPassword() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('[email protected]'); | ||
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false); | ||
|
@@ -342,7 +350,7 @@ public function testCreateSendPasswordByMailWithEnforcedPasswordProtectionWithPe | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
|
||
$share->expects($this->once())->method('getPassword')->willReturn(null); | ||
|
@@ -366,10 +374,12 @@ public function testCreateSendPasswordByMailWithEnforcedPasswordProtectionWithPe | |
]); | ||
$this->mailer->expects($this->once())->method('send'); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
public function testCreateSendPasswordByMailWithPasswordAndWithEnforcedPasswordProtectionWithPermanentPassword() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('[email protected]'); | ||
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(false); | ||
|
@@ -384,7 +394,7 @@ public function testCreateSendPasswordByMailWithPasswordAndWithEnforcedPasswordP | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
|
||
$share->expects($this->once())->method('getPassword')->willReturn('password'); | ||
|
@@ -410,10 +420,12 @@ public function testCreateSendPasswordByMailWithPasswordAndWithEnforcedPasswordP | |
]); | ||
$this->mailer->expects($this->once())->method('send'); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
public function testCreateSendPasswordByTalkWithEnforcedPasswordProtectionWithPermanentPassword() { | ||
$expectedShare = $this->createMock(IShare::class); | ||
|
||
$share = $this->getMockBuilder(IShare::class)->getMock(); | ||
$share->expects($this->any())->method('getSharedWith')->willReturn('[email protected]'); | ||
$share->expects($this->any())->method('getSendPasswordByTalk')->willReturn(true); | ||
|
@@ -428,7 +440,7 @@ public function testCreateSendPasswordByTalkWithEnforcedPasswordProtectionWithPe | |
$instance->expects($this->once())->method('createMailShare')->with($share)->willReturn(42); | ||
$instance->expects($this->once())->method('createShareActivity')->with($share); | ||
$instance->expects($this->once())->method('getRawShare')->with(42)->willReturn(['rawShare']); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($this->createMock(IShare::class)); | ||
$instance->expects($this->once())->method('createShareObject')->with(['rawShare'])->willReturn($expectedShare); | ||
$share->expects($this->any())->method('getNode')->willReturn($node); | ||
|
||
$share->expects($this->once())->method('getPassword')->willReturn(null); | ||
|
@@ -458,7 +470,7 @@ public function testCreateSendPasswordByTalkWithEnforcedPasswordProtectionWithPe | |
$user->expects($this->once())->method('getDisplayName')->willReturn('Owner display name'); | ||
$user->expects($this->once())->method('getEMailAddress')->willReturn('[email protected]'); | ||
|
||
$this->assertInstanceOf(IShare::class, $instance->create($share)); | ||
$this->assertSame($expectedShare, $instance->create($share)); | ||
} | ||
|
||
|
||
|