mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
test: add tests for getMountsForUserAndPath
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
522663b9f0
commit
720e588727
1 changed files with 29 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ use OCA\Files_External\Service\DBConfigService;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Test\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
|
||||
|
|
@ -271,4 +272,32 @@ class DBConfigServiceTest extends TestCase {
|
|||
$this->assertEquals($id1, $mounts[0]['mount_id']);
|
||||
$this->assertEquals($id2, $mounts[1]['mount_id']);
|
||||
}
|
||||
|
||||
public static function mountsForPathProvider(): array {
|
||||
return [
|
||||
['/test/files/test/', false, ['/test']],
|
||||
['/test/files/test/', true, ['/test/more']],
|
||||
['/test/files/', false, ['/']],
|
||||
['/test/files/', true, ['/test', '/test/more', '/test2']],
|
||||
];
|
||||
}
|
||||
|
||||
#[DataProvider('mountsForPathProvider')]
|
||||
public function testGetMountsForUserAndPath(string $path, bool $forChildren, array $expectedMountPoints): void {
|
||||
sort($expectedMountPoints);
|
||||
$id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
|
||||
$this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
|
||||
$id2 = $this->addMount('/test2', 'foo2', 'bar2', 100, DBConfigService::MOUNT_TYPE_PERSONAL);
|
||||
$this->dbConfig->addApplicable($id2, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
|
||||
$id3 = $this->addMount('/test/more', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
|
||||
$this->dbConfig->addApplicable($id3, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
|
||||
$id4 = $this->addMount('/', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
|
||||
$this->dbConfig->addApplicable($id4, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
|
||||
|
||||
$mounts = $this->dbConfig->getMountsForUserAndPath('test', [], $path, $forChildren);
|
||||
$mountPoints = array_map(fn (array $mountInfo) => $mountInfo['mount_point'], $mounts);
|
||||
sort($mountPoints);
|
||||
$this->assertEquals($expectedMountPoints, $mountPoints);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue