/** * 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'); }
/** * 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 Exception\RuntimeException('Error on list items: ' . $this->rackspace->getErrorMsg()); } $resultArray = array(); if (!empty($files)) { foreach ($files as $file) { $resultArray[] = $file->getName(); } } return $resultArray; }
/** * Test the get of a container * * @return void */ public function testGetContainer() { $this->_files->getHttpClient() ->setAdapter($this->_httpClientAdapterTest); $this->_httpClientAdapterTest->setResponse($this->_loadResponse('../../_files/testAuthenticate')); $this->assertTrue($this->_files->authenticate(),'Authentication failed'); $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__)); $container= $this->_files->getContainer('foo'); $this->assertTrue($this->_files->isSuccessful(),'Get container failed'); $this->assertEquals($container->getName(),'foo','The name of container is wrong'); $this->assertEquals($container->getSize(),9756,'The size in bytes is wrong'); $this->assertEquals($container->getObjectCount(),2,'The objects count is wrong'); $metadata= array( 'foo' => 'bar', 'foo2' => 'bar2' ); $this->assertEquals($container->getMetadata(),$metadata,'The metadata is wrong'); }