-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathMapperTest.php
More file actions
51 lines (42 loc) · 1.27 KB
/
MapperTest.php
File metadata and controls
51 lines (42 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\Mapper;
use OCP\IUser;
class MapperTest extends \Test\TestCase {
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
private $user;
protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
}
public static function dataGetBucket(): array {
return [
['user', 64, 0, '17'],
['user', 64, 64, '64'],
['USER', 64, 0, '0'],
['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, 0, '56'],
['user', 8, 0, '1'],
['user', 2, 0, '1'],
['USER', 2, 0, '0'],
['user', 128, 64, '81'],
];
}
/**
* @param string $username
* @param int $numBuckets
* @param string $expectedBucket
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataGetBucket')]
public function testGetBucket($username, $numBuckets, $bucketShift, $expectedBucket): void {
$mapper = new Mapper($this->user, ['arguments' => ['min_bucket' => $bucketShift]]);
$this->user->method('getUID')
->willReturn($username);
$result = $mapper->getBucket($numBuckets);
$this->assertEquals($expectedBucket, $result);
}
}