示例#1
0
 public function testCanHandleDomainsWithDots()
 {
     $postObject = new PostObject($this->client, 'foo.bar');
     $postObject->prepareData();
     $formAttrs = $postObject->getFormAttributes();
     $this->assertEquals('https://s3.amazonaws.com/foo.bar', $formAttrs['action']);
 }
示例#2
0
 /**
  * @dataProvider getDataForPostObjectTest
  */
 public function testGetPostObjectData(array $options, array $expected)
 {
     $postObject = new PostObject($this->client, 'foo', $options);
     $postObject->prepareData();
     $this->assertSame($expected['attributes'], $postObject->getFormAttributes());
     $this->assertSame($expected['inputs'], $postObject->getFormInputs());
     $this->assertSame($expected['policy'], $postObject->getJsonPolicy());
 }
示例#3
0
 public function testPostObjectProducesCorrectParametersForPost()
 {
     $key = 'dummy.txt';
     // Create the PostObject and fetch the data
     $post = new PostObject($this->client, $this->bucket);
     $post->prepareData();
     $form = $post->getFormAttributes();
     $data = $post->getFormInputs();
     // Use Guzzle to simulate a browser POST upload to S3
     $http = new Client(array('ssl.certificate_authority' => false));
     /** @var $response \Guzzle\Http\Message\Response */
     $response = $http->post($form['action'], null, $data)->addPostFiles(array('file' => __DIR__ . DIRECTORY_SEPARATOR . $key))->send();
     // Verify that the response is as expected
     $this->assertEquals(204, $response->getStatusCode());
     $this->assertEquals("https://{$this->bucket}.s3.amazonaws.com/{$key}", $response->getLocation());
     // Delete the object
     $this->client->deleteObject(array('Bucket' => $this->bucket, 'Key' => $key));
 }