filesystem.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Robin Appelman
  6. * @copyright 2012 Robin Appelman icewind@owncloud.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. class Test_Filesystem extends UnitTestCase{
  23. /**
  24. * @var array tmpDirs
  25. */
  26. private $tmpDirs;
  27. /**
  28. * @return array
  29. */
  30. private function getStorageData(){
  31. $dir=OC_Helper::tmpFolder();
  32. $this->tmpDirs[]=$dir;
  33. return array('datadir'=>$dir);
  34. }
  35. public function tearDown(){
  36. foreach($this->tmpDirs as $dir){
  37. OC_Helper::rmdirr($dir);
  38. }
  39. }
  40. public function setUp(){
  41. OC_Filesystem::clearMounts();
  42. }
  43. public function testMount(){
  44. OC_Filesystem::mount('OC_Filestorage_Local',self::getStorageData(),'/');
  45. $this->assertEqual('/',OC_Filesystem::getMountPoint('/'));
  46. $this->assertEqual('/',OC_Filesystem::getMountPoint('/some/folder'));
  47. $this->assertEqual('',OC_Filesystem::getInternalPath('/'));
  48. $this->assertEqual('some/folder',OC_Filesystem::getInternalPath('/some/folder'));
  49. OC_Filesystem::mount('OC_Filestorage_Local',self::getStorageData(),'/some');
  50. $this->assertEqual('/',OC_Filesystem::getMountPoint('/'));
  51. $this->assertEqual('/some/',OC_Filesystem::getMountPoint('/some/folder'));
  52. $this->assertEqual('/some/',OC_Filesystem::getMountPoint('/some/'));
  53. $this->assertEqual('/',OC_Filesystem::getMountPoint('/some'));
  54. $this->assertEqual('folder',OC_Filesystem::getInternalPath('/some/folder'));
  55. }
  56. }
  57. ?>