Blame view

sources/apps/files_external/tests/swift.php 1.58 KB
03e52840d   Kload   Init
1
  <?php
31b7f2792   Kload   Upgrade to ownclo...
2

03e52840d   Kload   Init
3
  /**
31b7f2792   Kload   Upgrade to ownclo...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
   * ownCloud
   *
   * @author Christian Berendt
   * @copyright 2013 Christian Berendt berendt@b1-systems.de
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
   * License as published by the Free Software Foundation; either
   * version 3 of the License, or any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
   *
   * You should have received a copy of the GNU Affero General Public
   * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
03e52840d   Kload   Init
21
22
23
   */
  
  namespace Test\Files\Storage;
31b7f2792   Kload   Upgrade to ownclo...
24
  class Swift extends Storage {
03e52840d   Kload   Init
25
26
27
  	private $config;
  
  	public function setUp() {
03e52840d   Kload   Init
28
  		$this->config = include('files_external/tests/config.php');
31b7f2792   Kload   Upgrade to ownclo...
29
30
31
  		if (!is_array($this->config) or !isset($this->config['swift'])
                      or !$this->config['swift']['run']) {
  			$this->markTestSkipped('OpenStack Object Storage backend not configured');
03e52840d   Kload   Init
32
  		}
31b7f2792   Kload   Upgrade to ownclo...
33
  		$this->instance = new \OC\Files\Storage\Swift($this->config['swift']);
03e52840d   Kload   Init
34
  	}
03e52840d   Kload   Init
35
36
  	public function tearDown() {
  		if ($this->instance) {
31b7f2792   Kload   Upgrade to ownclo...
37
  			$connection = $this->instance->getConnection();
6d9380f96   Cédric Dupont   Update sources OC...
38
  			$container = $connection->getContainer($this->config['swift']['bucket']);
31b7f2792   Kload   Upgrade to ownclo...
39

6d9380f96   Cédric Dupont   Update sources OC...
40
41
42
43
  			$objects = $container->objectList();
  			while($object = $objects->next()) {
  				$object->setName(str_replace('#','%23',$object->getName()));
  				$object->delete();
31b7f2792   Kload   Upgrade to ownclo...
44
  			}
6d9380f96   Cédric Dupont   Update sources OC...
45
  			$container->delete();
03e52840d   Kload   Init
46
47
48
  		}
  	}
  }