MapperTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @author Roeland Jago Douma <rullzer@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2016, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Test\Files\ObjectStore;
  22. use OC\Files\ObjectStore\Mapper;
  23. use OCP\IUser;
  24. class MapperTest extends \Test\TestCase {
  25. public function dataGetBucket() {
  26. return [
  27. ['user', 64, '17'],
  28. ['USER', 64, '0'],
  29. ['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, '56'],
  30. ['user', 8, '1'],
  31. ['user', 2, '1'],
  32. ['USER', 2, '0'],
  33. ];
  34. }
  35. /**
  36. * @dataProvider dataGetBucket
  37. * @param string $username
  38. * @param int $numBuckets
  39. * @param string $expectedBucket
  40. */
  41. public function testGetBucket($username, $numBuckets, $expectedBucket) {
  42. $user = $this->createMock(IUser::class);
  43. $user->method('getUID')
  44. ->willReturn($username);
  45. $mapper = new Mapper($user);
  46. $this->assertSame($expectedBucket, $mapper->getBucket($numBuckets));
  47. }
  48. }