usercache.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_Hook::clear('OC_Filesystem');
  34. //set up temporary storage
  35. $this->storage = \OC\Files\Filesystem::getStorage('/');
  36. \OC\Files\Filesystem::clearMounts();
  37. $storage = new \OC\Files\Storage\Temporary(array());
  38. \OC\Files\Filesystem::mount($storage,array(),'/');
  39. $datadir = str_replace('local::', '', $storage->getId());
  40. $this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT.'/data/cache');
  41. \OC_Config::setValue('cachedirectory', $datadir);
  42. \OC_User::clearBackends();
  43. \OC_User::useBackend(new \OC_User_Dummy());
  44. //login
  45. \OC_User::createUser('test', 'test');
  46. $this->user = \OC_User::getUser();
  47. \OC_User::setUserId('test');
  48. //set up the users dir
  49. $rootView=new \OC\Files\View('');
  50. $rootView->mkdir('/test');
  51. $this->instance=new \OC\Cache\UserCache();
  52. }
  53. protected function tearDown() {
  54. \OC_User::setUserId($this->user);
  55. \OC_Config::setValue('cachedirectory', $this->datadir);
  56. // Restore the original mount point
  57. \OC\Files\Filesystem::clearMounts();
  58. \OC\Files\Filesystem::mount($this->storage, array(), '/');
  59. parent::tearDown();
  60. }
  61. }