file.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. namespace Test\Cache;
  23. class FileCache extends \Test_Cache {
  24. private $user;
  25. private $datadir;
  26. function skip() {
  27. //$this->skipUnless(OC_User::isLoggedIn());
  28. }
  29. public function setUp() {
  30. //clear all proxies and hooks so we can do clean testing
  31. \OC_FileProxy::clearProxies();
  32. \OC_Hook::clear('OC_Filesystem');
  33. //disabled atm
  34. //enable only the encryption hook if needed
  35. //if(OC_App::isEnabled('files_encryption')) {
  36. // OC_FileProxy::register(new OC_FileProxy_Encryption());
  37. //}
  38. //set up temporary storage
  39. \OC\Files\Filesystem::clearMounts();
  40. $storage = new \OC\Files\Storage\Temporary(array());
  41. \OC\Files\Filesystem::mount($storage,array(),'/');
  42. $datadir = str_replace('local::', '', $storage->getId());
  43. $this->datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT.'/data');
  44. \OC_Config::setValue('datadirectory', $datadir);
  45. \OC_User::clearBackends();
  46. \OC_User::useBackend(new \OC_User_Dummy());
  47. //login
  48. \OC_User::createUser('test', 'test');
  49. $this->user = \OC_User::getUser();
  50. \OC_User::setUserId('test');
  51. //set up the users dir
  52. $rootView = new \OC\Files\View('');
  53. $rootView->mkdir('/test');
  54. $this->instance=new \OC\Cache\File();
  55. }
  56. public function tearDown() {
  57. \OC_User::setUserId($this->user);
  58. \OC_Config::setValue('datadirectory', $this->datadir);
  59. }
  60. }