You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usercache.php 2.3KB

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