2014-09-24 19:50:33 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2014 Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test\Connector\Sabre;
|
|
|
|
|
2014-11-11 01:30:38 +03:00
|
|
|
class Node extends \Test\TestCase {
|
2014-09-24 19:50:33 +04:00
|
|
|
public function davPermissionsProvider() {
|
|
|
|
return array(
|
2014-11-25 18:28:41 +03:00
|
|
|
array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RDNVW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RDNVCK'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRDNVW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMDNVW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SDNVW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RDNV'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RDNVW'),
|
|
|
|
array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RDNV'),
|
2014-09-24 19:50:33 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider davPermissionsProvider
|
|
|
|
*/
|
|
|
|
public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) {
|
|
|
|
$info = $this->getMockBuilder('\OC\Files\FileInfo')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType'))
|
|
|
|
->getMock();
|
|
|
|
$info->expects($this->any())
|
|
|
|
->method('getPermissions')
|
|
|
|
->will($this->returnValue($permissions));
|
|
|
|
$info->expects($this->any())
|
|
|
|
->method('isShared')
|
|
|
|
->will($this->returnValue($shared));
|
|
|
|
$info->expects($this->any())
|
|
|
|
->method('isMounted')
|
|
|
|
->will($this->returnValue($mounted));
|
|
|
|
$info->expects($this->any())
|
|
|
|
->method('getType')
|
|
|
|
->will($this->returnValue($type));
|
|
|
|
$view = $this->getMock('\OC\Files\View');
|
|
|
|
|
2015-02-12 14:29:01 +03:00
|
|
|
$node = new \OC\Connector\Sabre\File($view, $info);
|
2014-09-24 19:50:33 +04:00
|
|
|
$this->assertEquals($expected, $node->getDavPermissions());
|
|
|
|
}
|
|
|
|
}
|