示例#1
0
 /**
  * Cleaning up the test container so we can reuse it for other tests.
  */
 public static function tearDownAfterClass()
 {
     // First we get an identity
     $user = self::conf('hpcloud.identity.username');
     $pass = self::conf('hpcloud.identity.password');
     $tenantId = self::conf('hpcloud.identity.tenantId');
     $url = self::conf('hpcloud.identity.url');
     $ident = new \HPCloud\Services\IdentityServices($url);
     $token = $ident->authenticateAsUser($user, $pass, $tenantId);
     $region = self::conf('hpcloud.swift.region');
     // Then we need to get an instance of storage
     $store = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident, $region);
     // Delete the container and all the contents.
     $cname = self::$settings['hpcloud.swift.container'];
     try {
         $container = $store->container($cname);
     } catch (\HPCloud\Transport\FileNotFoundException $e) {
         return;
     }
     foreach ($container as $object) {
         try {
             $container->delete($object->name());
         } catch (\Exception $e) {
         }
     }
     $store->deleteContainer($cname);
 }
示例#2
0
 protected function objectStore($reset = FALSE)
 {
     if ($reset || empty(self::$ostore)) {
         $region = self::conf('hpcloud.swift.region');
         $ident = $this->identity($reset);
         $objStore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident, $region);
         self::$ostore = $objStore;
     }
     return self::$ostore;
 }
示例#3
0
 public function testNewFromIdentity()
 {
     $ident = $this->identity();
     $region = self::conf('hpcloud.swift.region');
     $ostore = \HPCloud\Storage\ObjectStorage::newFromIdentity($ident, $region);
     $this->assertInstanceOf('\\HPCloud\\Storage\\ObjectStorage', $ostore);
     $this->assertTrue(strlen($ostore->token()) > 0);
 }