/** * Set up the test case * * @return void */ public function setUp() { $this->rackspace = new Zend_Service_Rackspace_Files('foo', 'bar'); $this->httpClientAdapterTest = new Zend_Http_Client_Adapter_Test(); $this->rackspace->getHttpClient()->setAdapter($this->httpClientAdapterTest); // authentication (from a file) $this->httpClientAdapterTest->setResponse(self::loadResponse('../../_files/testAuthenticate')); $this->assertTrue($this->rackspace->authenticate(), 'Authentication failed'); $this->metadata = array('foo' => 'bar', 'foo2' => 'bar2'); $this->metadata2 = array('hello' => 'world'); // load the HTTP response (from a file) $this->httpClientAdapterTest->setResponse($this->loadResponse($this->getName())); }
/** * Set up the test case * * @return void */ public function setUp() { if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) { $this->markTestSkipped('Zend_Service_Rackspace_Files_OnlineTest tests are not enabled'); } if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) { $this->markTestSkipped('Constants User and Key have to be set.'); } $this->rackspace = new Zend_Service_Rackspace_Files(TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER, TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY); $this->httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket(); $this->rackspace->getHttpClient()->setAdapter(self::$httpClientAdapterSocket); $this->metadata = array('foo' => 'bar', 'foo2' => 'bar2'); $this->metadata2 = array('hello' => 'world'); // terms of use compliance: safe delay between each test sleep(2); }
/** * 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'); }
/** * Constructor * * @param array|Traversable $options * @return void */ function __construct($options = array()) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } if (!is_array($options) || empty($options)) { throw new Zend_Cloud_StorageService_Exception('Invalid options provided'); } try { $this->_rackspace = new Zend_Service_Rackspace_Files($options[self::USER], $options[self::API_KEY]); } catch (Zend_Service_Rackspace_Exception $e) { throw new Zend_Cloud_StorageService_Exception('Error on create: ' . $e->getMessage(), $e->getCode(), $e); } if (isset($options[self::HTTP_ADAPTER])) { $this->_rackspace->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]); } if (!empty($options[self::REMOTE_CONTAINER])) { $this->_container = $options[self::REMOTE_CONTAINER]; } }
public function testCopyObject() { $result = $this->rackspace->copyObject('zf-unit-test', 'zf-object-test', 'zf-unit-test', 'zf-object-test' . '-copy'); $this->assertTrue($result); $this->assertNotContains('application/x-www-form-urlencoded', $this->rackspace->getHttpClient()->getLastRequest()); }