Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable11] Add unit tests for mounts of delete users #4474

Merged
merged 1 commit into from
Apr 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/lib/Files/Config/UserMountCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function setUp() {
$userBackend = new Dummy();
$userBackend->createUser('u1', '');
$userBackend->createUser('u2', '');
$userBackend->createUser('u3', '');
$this->userManager->registerBackend($userBackend);
$this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(Log::class));
}
Expand Down Expand Up @@ -211,6 +212,7 @@ public function testChangeMountId() {
public function testGetMountsForUser() {
$user1 = $this->userManager->get('u1');
$user2 = $this->userManager->get('u2');
$user3 = $this->userManager->get('u3');

list($storage1, $id1) = $this->getStorage(1);
list($storage2, $id2) = $this->getStorage(2);
Expand All @@ -219,9 +221,12 @@ public function testGetMountsForUser() {

$this->cache->registerMounts($user1, [$mount1, $mount2]);
$this->cache->registerMounts($user2, [$mount2]);
$this->cache->registerMounts($user3, [$mount2]);

$this->clearCache();

$user3->delete();

$cachedMounts = $this->cache->getMountsForUser($user1);

$this->assertCount(2, $cachedMounts);
Expand All @@ -234,6 +239,9 @@ public function testGetMountsForUser() {
$this->assertEquals($user1, $cachedMounts[1]->getUser());
$this->assertEquals($id2, $cachedMounts[1]->getRootId());
$this->assertEquals(2, $cachedMounts[1]->getStorageId());

$cachedMounts = $this->cache->getMountsForUser($user3);
$this->assertEmpty($cachedMounts);
}

public function testGetMountsByStorageId() {
Expand Down Expand Up @@ -431,4 +439,20 @@ public function testGetMountsForFileIdSubFolderMountOutside() {

$this->assertCount(0, $cachedMounts);
}


public function testGetMountsForFileIdDeletedUser() {
$user1 = $this->userManager->get('u1');

list($storage1, $rootId) = $this->getStorage(2);
$rootId = $this->createCacheEntry('', 2);
$mount1 = new MountPoint($storage1, '/foo/');
$this->cache->registerMounts($user1, [$mount1]);

$user1->delete();
$this->clearCache();

$cachedMounts = $this->cache->getMountsForFileId($rootId);
$this->assertEmpty($cachedMounts);
}
}