mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
test: add test for updating cached mounts with multiple entries for root id
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
c29c7023d9
commit
d14c4082e1
1 changed files with 26 additions and 3 deletions
|
|
@ -184,7 +184,7 @@ class UserMountCacheTest extends TestCase {
|
|||
->expects($this->exactly(2))
|
||||
->method('dispatchTyped')
|
||||
->with($this->callback(function (UserMountAddedEvent|UserMountRemovedEvent $event) use (&$operation) {
|
||||
return match(++$operation) {
|
||||
return match (++$operation) {
|
||||
1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/asd/',
|
||||
2 => $event instanceof UserMountRemovedEvent && $event->mountPoint->getMountPoint() === '/asd/',
|
||||
default => false,
|
||||
|
|
@ -215,7 +215,7 @@ class UserMountCacheTest extends TestCase {
|
|||
->expects($this->exactly(3))
|
||||
->method('dispatchTyped')
|
||||
->with($this->callback(function (UserMountAddedEvent|UserMountRemovedEvent $event) use (&$operation) {
|
||||
return match(++$operation) {
|
||||
return match (++$operation) {
|
||||
1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/bar/',
|
||||
2 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/foo/',
|
||||
3 => $event instanceof UserMountRemovedEvent && $event->mountPoint->getMountPoint() === '/bar/',
|
||||
|
|
@ -251,7 +251,7 @@ class UserMountCacheTest extends TestCase {
|
|||
->expects($this->exactly(2))
|
||||
->method('dispatchTyped')
|
||||
->with($this->callback(function (UserMountAddedEvent|UserMountUpdatedEvent $event) use (&$operation) {
|
||||
return match(++$operation) {
|
||||
return match (++$operation) {
|
||||
1 => $event instanceof UserMountAddedEvent && $event->mountPoint->getMountPoint() === '/foo/',
|
||||
2 => $event instanceof UserMountUpdatedEvent && $event->oldMountPoint->getMountId() === null && $event->newMountPoint->getMountId() === 1,
|
||||
default => false,
|
||||
|
|
@ -596,4 +596,27 @@ class UserMountCacheTest extends TestCase {
|
|||
$this->assertCount(1, $cachedMounts);
|
||||
$this->assertEquals('dummy', $cachedMounts[$this->keyForMount($mount1)]->getMountProvider());
|
||||
}
|
||||
|
||||
public function testChangedSameRootId(): void {
|
||||
$user = $this->userManager->get('u1');
|
||||
|
||||
[$storage] = $this->getStorage(10);
|
||||
$mount1 = new MountPoint($storage, '/asd/');
|
||||
$mount2 = new MountPoint($storage, '/asd2/');
|
||||
|
||||
$this->cache->registerMounts($user, [$mount1, $mount2]);
|
||||
|
||||
$mount2 = new MountPoint($storage, '/asd2/', null, null, null, 1);
|
||||
$this->cache->registerMounts($user, [$mount1, $mount2]);
|
||||
|
||||
$this->cache->flush();
|
||||
$cached = $this->cache->getMountsForUser($user);
|
||||
usort($cached, fn (ICachedMountInfo $a, ICachedMountInfo $b) => $a->getMountPoint() <=> $b->getMountPoint());
|
||||
|
||||
$mountPoints = array_map(fn (ICachedMountInfo $mountInfo) => $mountInfo->getMountPoint(), $cached);
|
||||
$this->assertEquals(['/asd/', '/asd2/'], $mountPoints);
|
||||
|
||||
$mountIds = array_map(fn (ICachedMountInfo $mountInfo) => $mountInfo->getMountId(), $cached);
|
||||
$this->assertEquals([null, 1], $mountIds);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue