file.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /** @var string */
  25. private $user;
  26. /** @var string */
  27. private $datadir;
  28. /** @var \OC\Files\Storage\Storage */
  29. private $storage;
  30. function skip() {
  31. //$this->skipUnless(OC_User::isLoggedIn());
  32. }
  33. protected function setUp() {
  34. parent::setUp();
  35. //clear all proxies and hooks so we can do clean testing
  36. \OC_Hook::clear('OC_Filesystem');
  37. //set up temporary storage
  38. $this->storage = \OC\Files\Filesystem::getStorage('/');
  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('cachedirectory', \OC::$SERVERROOT.'/data/cache');
  44. \OC_Config::setValue('cachedirectory', $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. protected function tearDown() {
  57. \OC_User::setUserId($this->user);
  58. \OC_Config::setValue('cachedirectory', $this->datadir);
  59. // Restore the original mount point
  60. \OC\Files\Filesystem::clearMounts();
  61. \OC\Files\Filesystem::mount($this->storage, array(), '/');
  62. parent::tearDown();
  63. }
  64. }