public static function getInterestingCreateBlobOptions()
 {
     $ret = array();
     $options = new CreateBlobOptions();
     array_push($ret, $options);
     $options = new CreateBlobOptions();
     $options->setTimeout(10);
     array_push($ret, $options);
     $options = new CreateBlobOptions();
     $options->setTimeout(-10);
     array_push($ret, $options);
     $options = new CreateBlobOptions();
     $metadata = array('foo' => 'bar', 'foo2' => 'bar2', 'foo3' => 'bar3');
     $options->setMetadata($metadata);
     $options->setTimeout(10);
     array_push($ret, $options);
     $options = new CreateBlobOptions();
     $metadata = array('foo' => 'bar');
     $options->setMetadata($metadata);
     $options->setTimeout(-10);
     array_push($ret, $options);
     return $ret;
 }
 /**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobMetadata
  */
 public function testGetBlobMetadataWorks()
 {
     // Act
     $container = self::$_test_container_for_blobs;
     $blob = 'test';
     $opts = new CreateBlobOptions();
     $metadata = $opts->getMetadata();
     $metadata['test'] = 'bar';
     $metadata['blah'] = 'bleah';
     $opts->setMetadata($metadata);
     $this->restProxy->createPageBlob($container, $blob, 4096, $opts);
     $props = $this->restProxy->getBlobMetadata($container, $blob);
     // Assert
     $this->assertNotNull($props, '$props');
     $this->assertNotNull($props->getETag(), '$props->getETag()');
     $this->assertNotNull($props->getMetadata(), '$props->getMetadata()');
     $this->assertEquals(2, count($props->getMetadata()), 'count($props->getMetadata())');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('test', $props->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'test\', $props->getMetadata())');
     $this->assertTrue(!(array_search('bar', $props->getMetadata()) === FALSE), '!(array_search(\'bar\', $props->getMetadata()) === FALSE)');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('blah', $props->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'blah\', $props->getMetadata())');
     $this->assertTrue(!(array_search('bleah', $props->getMetadata()) === FALSE), '!(array_search(\'bleah\', $props->getMetadata()) === FALSE)');
     $this->assertNotNull($props->getLastModified(), '$props->getLastModified()');
 }
 /**
  * @covers MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions::getMetadata
  */
 public function testGetMetadata()
 {
     // Setup
     $container = new CreateBlobOptions();
     $expected = array('key1' => 'value1', 'key2' => 'value2');
     $container->setMetadata($expected);
     // Test
     $actual = $container->getMetadata();
     // Assert
     $this->assertEquals($expected, $actual);
 }
예제 #4
0
 /**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader
  * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create
  */
 public function testGetBlobGarbage()
 {
     // Setup
     $name = 'getblobwithgarbage' . $this->createSuffix();
     $blob = 'myblob';
     $metadata = array('m1' => 'v1', 'm2' => 'v2');
     $contentType = 'text/plain; charset=UTF-8';
     $contentStream = chr(0);
     $this->createContainer($name);
     $options = new CreateBlobOptions();
     $options->setContentType($contentType);
     $options->setMetadata($metadata);
     $this->restProxy->createBlockBlob($name, $blob, $contentStream, $options);
     // Test
     $result = $this->restProxy->getBlob($name, $blob);
     // Assert
     $this->assertEquals(BlobType::BLOCK_BLOB, $result->getProperties()->getBlobType());
     $this->assertEquals($metadata, $result->getMetadata());
     $this->assertEquals($contentStream, stream_get_contents($result->getContentStream()));
 }