示例#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);
 }
示例#2
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     // Create the bucket here
     $s3 = new AmazonS3($this->_config->get(\Zend\Cloud\StorageService\Adapter\S3::AWS_ACCESS_KEY), $this->_config->get(\Zend\Cloud\StorageService\Adapter\S3::AWS_SECRET_KEY));
     $s3->createBucket($this->_config->get(\Zend\Cloud\StorageService\Adapter\S3::BUCKET_NAME));
 }