node.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Thomas Müller <thomas.mueller@tmit.eu>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Connector\Sabre;
  9. class Node extends \Test\TestCase {
  10. public function davPermissionsProvider() {
  11. return array(
  12. array(\OCP\Constants::PERMISSION_ALL, 'file', false, false, 'RDNVW'),
  13. array(\OCP\Constants::PERMISSION_ALL, 'dir', false, false, 'RDNVCK'),
  14. array(\OCP\Constants::PERMISSION_ALL, 'file', true, false, 'SRDNVW'),
  15. array(\OCP\Constants::PERMISSION_ALL, 'file', true, true, 'SRMDNVW'),
  16. array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_SHARE, 'file', true, false, 'SDNVW'),
  17. array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_UPDATE, 'file', false, false, 'RDNV'),
  18. array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_DELETE, 'file', false, false, 'RW'),
  19. array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'file', false, false, 'RDNVW'),
  20. array(\OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, 'dir', false, false, 'RDNV'),
  21. );
  22. }
  23. /**
  24. * @dataProvider davPermissionsProvider
  25. */
  26. public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) {
  27. $info = $this->getMockBuilder('\OC\Files\FileInfo')
  28. ->disableOriginalConstructor()
  29. ->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType'))
  30. ->getMock();
  31. $info->expects($this->any())
  32. ->method('getPermissions')
  33. ->will($this->returnValue($permissions));
  34. $info->expects($this->any())
  35. ->method('isShared')
  36. ->will($this->returnValue($shared));
  37. $info->expects($this->any())
  38. ->method('isMounted')
  39. ->will($this->returnValue($mounted));
  40. $info->expects($this->any())
  41. ->method('getType')
  42. ->will($this->returnValue($type));
  43. $view = $this->getMock('\OC\Files\View');
  44. $node = new \OC\Connector\Sabre\File($view, $info);
  45. $this->assertEquals($expected, $node->getDavPermissions());
  46. }
  47. }