diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-05-22 21:14:28 +0200 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-05-23 20:42:08 +0200 |
commit | 12b63258d55b3d8766983b12070469426e66942d (patch) | |
tree | 2df69741c456974aa2cc5e36ced78c94f7e9b9e0 /tests/lib/Files/ObjectStore | |
parent | 5e2316d05d954ec9cb9a3d284007c3d329550395 (diff) | |
download | nextcloud-server-12b63258d55b3d8766983b12070469426e66942d.tar.gz nextcloud-server-12b63258d55b3d8766983b12070469426e66942d.zip |
Add mapper unit tests
Diffstat (limited to 'tests/lib/Files/ObjectStore')
-rw-r--r-- | tests/lib/Files/ObjectStore/MapperTest.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php new file mode 100644 index 00000000000..1ebb67a6905 --- /dev/null +++ b/tests/lib/Files/ObjectStore/MapperTest.php @@ -0,0 +1,50 @@ +<?php +/** + * @author Roeland Jago Douma <rullzer@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace Test\Files\ObjectStore; + + +use OC\Files\ObjectStore\Mapper; + +class MapperTest extends \Test\TestCase { + + public function dataGetBucket() { + return [ + ['user', substr(md5('user'), 0, 3)], + ['USER', substr(md5('USER'), 0, 3)], + ['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', substr(md5('bc0e8b52-a66c-1035-90c6-d9663bda9e3f'), 0, 3)], + ]; + } + + /** + * @dataProvider dataGetBucket + * @param string $username + * @param string $expectedBucket + */ + public function testGetBucket($username, $expectedBucket) { + $user = $this->getMock('OCP\IUser'); + $user->method('getUID') + ->willReturn($username); + + $mapper = new Mapper($user); + + $this->assertSame($expectedBucket, $mapper->getBucket()); + } +}
\ No newline at end of file |