Exemplo n.º 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']);
 }
Exemplo n.º 2
0
 public function testClientAndBucketGettersAndSetters()
 {
     $postObject = new PostObject($this->client, 'foo');
     $client2 = $this->getServiceBuilder()->get('s3');
     $this->assertSame($this->client, $postObject->getClient());
     $this->assertSame('foo', $postObject->getBucket());
     $postObject->setClient($client2)->setBucket('bar');
     $this->assertSame($client2, $postObject->getClient());
     $this->assertSame('bar', $postObject->getBucket());
 }
Exemplo n.º 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));
 }