/** * Test create bucket * * @return void */ public function testCreateBuckets() { //Valid bucket name $bucket = 'iamavalidbucket'; $location = ''; $accessKey = 'AKIAIDCZ2WXN6NNB7YZA'; $secretKey = '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'; $requestDate = DateTime::createFromFormat(DateTime::RFC1123, 'Tue, 15 May 2012 15:18:31 +0000'); $this->amazon->setRequestDate($requestDate); $this->amazon->setKeys($accessKey, $secretKey); //Fake keys /** * Check of request inside _makeRequest * */ $this->uriHttp->expects($this->once())->method('getHost')->with()->will($this->returnValue('s3.amazonaws.com')); $this->uriHttp->expects($this->once())->method('setHost')->with('iamavalidbucket.s3.amazonaws.com'); $this->uriHttp->expects($this->once())->method('setPath')->with('/'); $this->httpClient->expects($this->once())->method('setUri')->with($this->uriHttp); $this->httpClient->expects($this->once())->method('setMethod')->with('PUT'); $this->httpClient->expects($this->once())->method('setHeaders')->with(array("Date" => "Tue, 15 May 2012 15:18:31 +0000", "Content-Type" => "application/xml", "Authorization" => "AWS " . $accessKey . ":Y+T4nZxI1wBi1Yn1BMnOK9CDiOM=")); /** * Fake response inside _makeRequest * */ // Http Response results $this->httpResponse->expects($this->any())->method('getStatusCode')->will($this->returnValue(200)); // Expects to be called only once the method send() then return a Http Response. $this->httpClient->expects($this->once())->method('send')->will($this->returnValue($this->httpResponse)); $response = $this->amazon->createBucket($bucket, $location); $this->assertTrue($response); }
/** * Sets up this test case * * @return void */ public function setUp() { parent::setUp(); // Create the bucket here $s3 = new AmazonS3($this->_config->get(\ZendCloud\StorageService\Adapter\S3::AWS_ACCESS_KEY), $this->_config->get(\ZendCloud\StorageService\Adapter\S3::AWS_SECRET_KEY)); $s3->createBucket($this->_config->get(\ZendCloud\StorageService\Adapter\S3::BUCKET_NAME)); }