示例#1
0
 /**
  * @covers mychaelstyle\storage\providers\AmazonS3::put
  * @covers mychaelstyle\storage\providers\AmazonS3::remove
  * @covers mychaelstyle\storage\providers\AmazonS3::__mergePutOptions
  * @covers mychaelstyle\storage\providers\AmazonS3::__formatUri
  */
 public function testPut()
 {
     if ($this->markIncompleteIfNoNetwork()) {
         return true;
     }
     $expected = file_get_contents($this->path_example);
     // put a example file
     $options = array('contentType' => 'text/plain;charset=UTF8');
     $this->object->put($this->path_example, $this->uri, $options);
     $options = array('contentType' => 'text/plain');
     $options['contentType'] = null;
     $options['acl'] = 'private';
     //$options['curl.options'] = array(CURLOPT_SSL_VERIFYPEER => false);
     $this->object->put($this->path_example, $this->uri, $options);
 }
 /**
  * testPutWithMoreHeaders
  *
  * @return void
  * @author Rob Mcvey
  **/
 public function testPutWithMoreHeaders()
 {
     $file_path = APP . 'Plugin' . DS . 'AmazonS3' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'files' . DS . 'dots.csv';
     $this->AmazonS3->setDate('Mon, 23 Sep 2013 08:46:05 GMT');
     // Mock the built request
     $expectedRequest = array('method' => 'PUT', 'uri' => array('host' => 'bucket.s3.amazonaws.com', 'scheme' => 'https', 'path' => 'some/dir/in/the/bucket/dots.csv'), 'header' => array('Accept' => '*/*', 'User-Agent' => 'CakePHP', 'Date' => 'Mon, 23 Sep 2013 08:46:05 GMT', 'Authorization' => 'AWS foo:WxdnOvuaK37BwO72xShLSFu80LI=', 'Content-MD5' => 'L0O0L9gz0ed0IKja50GQAA==', 'Content-Type' => 'text/plain', 'Content-Length' => 3, 'X-Amz-Meta-ReviewedBy' => '*****@*****.**', 'x-amz-acl' => 'public-read'), 'body' => '...');
     // Mock the HttpSocket response
     $HttpSocketResponse = new stdClass();
     $HttpSocketResponse->body = '????JFIFdd??Duckya??Adobed??????????';
     $HttpSocketResponse->code = 200;
     $HttpSocketResponse->reasonPhrase = 'OK';
     $HttpSocketResponse->headers = array('x-amz-id-2' => '4589328529385938', 'x-amz-request-id' => 'GSDFGt45egdfsC', 'Date' => 'Mon, 23 Sep 2013 08:46:05 GMT', 'Last-Modified' => 'Tue, 29 Nov 2011 10:30:03 GMT', 'ETag' => '24562346dgdgsdgf2352"', 'Accept-Ranges' => 'bytes', 'Content-Type' => 'image/jpeg', 'Content-Length' => 0, 'Connection' => 'close', 'Server' => 'AmazonS3');
     // Mock the HttpSocket class
     $this->AmazonS3->HttpSocket = $this->getMock('HttpSocket');
     $this->AmazonS3->HttpSocket->expects($this->once())->method('request')->with($expectedRequest)->will($this->returnValue($HttpSocketResponse));
     $this->AmazonS3->amazonHeaders = array('x-amz-acl' => 'public-read', 'X-Amz-Meta-ReviewedBy' => '*****@*****.**');
     $this->AmazonS3->put($file_path, '/some/dir/in/the/bucket/');
 }