コード例 #1
0
ファイル: S3RestTest.php プロジェクト: rudrud/zf2
 /**
  * Test create bucket
  *
  * @return void
  */
 public function testCreateBuckets()
 {
     //Valid bucket name
     $bucket = 'iamavalidbucket';
     $location = '';
     $requestDate = new Date();
     $requestDate->set('Tue, 15 May 2012 15:18:31 +0000', Date::RFC_1123);
     $this->amazon->setRequestDate($requestDate);
     $this->amazon->setKeys('AKIAIDCZ2WXN6NNB7YZA', 'sagA0Lge8R+ifORcyb6Z/qVbmtimFCUczvh51Jq8');
     //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 AKIAIDCZ2WXN6NNB7YZA: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);
 }