Ejemplo n.º 1
0
 /**
  * @depends testHeadBucket
  */
 public function notestPutAndListObjects()
 {
     $this->client->waitUntil('bucket_exists', array('Bucket' => $this->bucket));
     $command = $this->client->getCommand('PutObject', array('Bucket' => $this->bucket, 'Key' => self::TEST_KEY, 'ContentMD5' => true, 'Body' => 'åbc 123', 'ContentType' => 'application/foo', 'ACP' => $this->acp, 'Metadata' => array('test' => '123', 'abc' => '@pples', 'foo' => '', 'null' => null, 'space' => ' ', 'zero' => '0', 'trim' => ' hi ')));
     self::log("Uploading an object");
     $result = $command->execute();
     // make sure the expect header wasn't sent
     $this->assertNull($command->getRequest()->getHeader('Expect'));
     $this->assertInstanceOf('Guzzle\\Service\\Resource\\Model', $result);
     $this->assertNotEmpty($result['ETag']);
     $this->client->waitUntil('object_exists', array('Bucket' => $this->bucket, 'Key' => self::TEST_KEY));
     self::log("HEAD the object");
     $result = $this->client->headObject(array('Bucket' => $this->bucket, 'Key' => self::TEST_KEY));
     $this->assertEquals('application/foo', $result['ContentType']);
     $this->assertEquals('123', $result['Metadata']['test']);
     $this->assertEquals('@pples', $result['Metadata']['abc']);
     // Ensure the object was created correctly
     self::log("GETting the object");
     $result = $this->client->getObject(array('Bucket' => $this->bucket, 'Key' => self::TEST_KEY));
     $this->assertInstanceOf('Guzzle\\Service\\Resource\\Model', $result);
     $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $result['Body']);
     $this->assertEquals('åbc 123', (string) $result['Body']);
     $this->assertEquals('application/foo', $result['ContentType']);
     $this->assertEquals('123', $result['Metadata']['test']);
     $this->assertEquals('@pples', $result['Metadata']['abc']);
     // Ensure the object was created and we can find it in the iterator
     self::log("Checking if the item is in the ListObjects results");
     $iterator = $this->client->getIterator('ListObjects', array('Bucket' => $this->bucket, 'Prefix' => self::TEST_KEY));
     $objects = $iterator->toArray();
     $this->assertEquals(1, count($objects));
     $this->assertEquals('foo', $objects[0]['Key']);
 }