swift.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @author Christian Berendt <berendt@b1-systems.de>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace Test\Files\Storage;
  26. class Swift extends Storage {
  27. private $config;
  28. protected function setUp() {
  29. parent::setUp();
  30. $this->config = include('files_external/tests/config.php');
  31. if (!is_array($this->config) or !isset($this->config['swift'])
  32. or !$this->config['swift']['run']) {
  33. $this->markTestSkipped('OpenStack Object Storage backend not configured');
  34. }
  35. $this->instance = new \OC\Files\Storage\Swift($this->config['swift']);
  36. }
  37. protected function tearDown() {
  38. if ($this->instance) {
  39. $connection = $this->instance->getConnection();
  40. $container = $connection->getContainer($this->config['swift']['bucket']);
  41. $objects = $container->objectList();
  42. while($object = $objects->next()) {
  43. $object->setName(str_replace('#','%23',$object->getName()));
  44. $object->delete();
  45. }
  46. $container->delete();
  47. }
  48. parent::tearDown();
  49. }
  50. }