Adjust mountprovider tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-12-08 17:30:08 +01:00
parent b8d2a00b74
commit 676d2b7a94
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 25 additions and 3 deletions

View File

@ -196,10 +196,10 @@ class ShareAPIControllerTest extends TestCase {
$this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
$this->shareManager
->expects($this->exactly(5))
->expects($this->exactly(6))
->method('getShareById')
->willReturnCallback(function ($id) {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42') {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42') {
throw new \OCP\Share\Exceptions\ShareNotFound();
} else {
throw new \Exception();

View File

@ -123,6 +123,12 @@ class MountProviderTest extends \Test\TestCase {
$this->makeMockShare(8, 102, 'user2', '/share6', 31),
$this->makeMockShare(9, 102, 'user2', '/share6', 31),
];
$deckShares = [
$this->makeMockShare(10, 103, 'user2', '/share7', 0),
$this->makeMockShare(11, 103, 'user1', '/share7', 31),
$this->makeMockShare(12, 103, 'user2', '/share7', 31),
$this->makeMockShare(13, 103, 'user2', '/share7', 31),
];
// tests regarding circles are made in the app itself.
$circleShares = [];
$this->user->expects($this->any())
@ -144,16 +150,21 @@ class MountProviderTest extends \Test\TestCase {
->method('getSharedWith')
->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares);
$this->shareManager->expects($this->at(4))
->method('getSharedWith')
->with('user1', IShare::TYPE_DECK, null, -1)
->willReturn($deckShares);
$this->shareManager->expects($this->any())
->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) {
return new \OC\Share20\Share($rootFolder, $userManager);
});
$mounts = $this->provider->getMountsForUser($this->user, $this->loader);
$this->assertCount(3, $mounts);
$this->assertCount(4, $mounts);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]);
$this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[3]);
$mountedShare1 = $mounts[0]->getShare();
$this->assertEquals('2', $mountedShare1->getId());
$this->assertEquals('user2', $mountedShare1->getShareOwner());
@ -172,6 +183,12 @@ class MountProviderTest extends \Test\TestCase {
$this->assertEquals(102, $mountedShare3->getNodeId());
$this->assertEquals('/share6', $mountedShare3->getTarget());
$this->assertEquals(31, $mountedShare3->getPermissions());
$mountedShare4 = $mounts[3]->getShare();
$this->assertEquals('12', $mountedShare4->getId());
$this->assertEquals('user2', $mountedShare4->getShareOwner());
$this->assertEquals(103, $mountedShare4->getNodeId());
$this->assertEquals('/share7', $mountedShare4->getTarget());
$this->assertEquals(31, $mountedShare4->getPermissions());
}
public function mergeSharesDataProvider() {
@ -337,6 +354,7 @@ class MountProviderTest extends \Test\TestCase {
// tests regarding circles are made in the app itself.
$circleShares = [];
$roomShares = [];
$deckShares = [];
$this->shareManager->expects($this->at(0))
->method('getSharedWith')
->with('user1', IShare::TYPE_USER)
@ -353,6 +371,10 @@ class MountProviderTest extends \Test\TestCase {
->method('getSharedWith')
->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares);
$this->shareManager->expects($this->at(4))
->method('getSharedWith')
->with('user1', IShare::TYPE_DECK, null, -1)
->willReturn($deckShares);
$this->shareManager->expects($this->any())
->method('newShare')
->willReturnCallback(function () use ($rootFolder, $userManager) {