/**
  * @covers WindowsAzure\Blob\Models\CreateBlobBlockOptions::setLeaseId
  * @covers WindowsAzure\Blob\Models\CreateBlobBlockOptions::getLeaseId
  */
 public function testSetLeaseId()
 {
     // Setup
     $expected = '0x8CAFB82EFF70C46';
     $options = new CreateBlobBlockOptions();
     $options->setLeaseId($expected);
     // Test
     $options->setLeaseId($expected);
     // Assert
     $this->assertEquals($expected, $options->getLeaseId());
 }
示例#2
0
 /**
  * Creates a new block to be committed as part of a block blob.
  * 
  * @param string                        $container name of the container
  * @param string                        $blob      name of the blob
  * @param string                        $blockId   must be less than or equal to 
  * 64 bytes in size. For a given blob, the length of the value specified for the
  * blockid parameter must be the same size for each block.
  * @param string                        $content   the blob block contents
  * @param Models\CreateBlobBlockOptions $options   optional parameters
  * 
  * @return none
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135726.aspx
  */
 public function createBlobBlock($container, $blob, $blockId, $content, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     Validate::isString($blockId, 'blockId');
     Validate::notNullOrEmpty($blockId, 'blockId');
     Validate::isTrue(is_string($content) || is_resource($content), sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource'));
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_CREATED;
     $body = $content;
     if (is_null($options)) {
         $options = new CreateBlobBlockOptions();
     }
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $this->addOptionalHeader($headers, Resources::CONTENT_MD5, $options->getContentMD5());
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'block');
     $this->addOptionalQueryParam($queryParams, Resources::QP_BLOCKID, base64_encode($blockId));
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
     return CopyBlobResult::create($response->getHeader());
 }