/**
  * Tears down this test case
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->_config) {
         return;
     }
     // Delete the container here
     $rackspace = new Zend_Service_Rackspace_Files($this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::USER), $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::API_KEY));
     $files = $rackspace->getObjects($this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER));
     if ($files == !false) {
         foreach ($files as $file) {
             $rackspace->deleteObject($this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER), $file->getName());
         }
     }
     $rackspace->deleteContainer($this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER));
     parent::tearDown();
 }
Exemple #2
0
 /**
  * Delete an object.
  *
  * @param string $file
  * @return boolean
  */
 public function deleteObject($file, $container = false)
 {
     if (!$container) {
         $container = $this->getGeneralContainer();
     }
     $this->_service->deleteObject($container, $file);
     return $this->_service->isSuccessful();
 }
 /**
  * Test the authentication error (401 Unauthorized - Bad username or password)
  *
  * @return void
  */
 public function testAuthenticateError()
 {
     $this->_files->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $this->assertFalse($this->_files->authenticate());
     $this->assertFalse($this->_files->isSuccessful());
     $this->assertEquals($this->_files->getErrorCode(), '401');
     $this->assertEquals($this->_files->getErrorMsg(), 'Bad username or password');
 }
Exemple #4
0
 /**
  * Get the CDN SSL URL of the object
  *
  * @return string
  */
 public function getCdnUrlSsl()
 {
     $result = $this->service->getInfoCdnContainer($this->container);
     if ($result !== false) {
         if ($result['cdn_enabled']) {
             return $result['cdn_uri_ssl'] . '/' . $this->name;
         }
     }
     return false;
 }
 /**
  * @group ZF-12542
  */
 public function testGetInfoCdnContainer()
 {
     $info = $this->rackspace->getInfoCdnContainer(TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME);
     $this->assertTrue($info !== false);
     $this->assertTrue(is_array($info));
     $this->assertTrue(!empty($info['ttl']));
     $this->assertTrue(!empty($info['cdn_uri']));
     $this->assertTrue(!empty($info['cdn_uri_ssl']));
     $this->assertTrue($info['cdn_enabled']);
     $this->assertTrue($info['log_retention']);
 }
Exemple #6
0
 /**
  * Return an array of the items contained in the given path.  The items
  * returned are the files or objects that in the specified path.
  *
  * @param  string $path
  * @param  array  $options
  * @return array
  */
 public function listItems($path, $options = null)
 {
     if (!empty($path)) {
         $options = array('prefix' => $path);
     }
     $files = $this->_rackspace->getObjects($this->_container, $options);
     if (!$this->_rackspace->isSuccessful()) {
         throw new Zend_Cloud_StorageService_Exception('Error on list items: ' . $this->_rackspace->getErrorMsg());
     }
     $resultArray = array();
     if (!empty($files)) {
         foreach ($files as $file) {
             $resultArray[] = $file->getName();
         }
     }
     return $resultArray;
 }
Exemple #7
0
 public function testDeleteContainer()
 {
     $this->assertTrue($this->rackspace->deleteContainer(TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME));
 }
 public function testDeleteContainer()
 {
     $this->assertTrue($this->rackspace->deleteContainer('zf-unit-test'));
 }