/**
  * @covers MicrosoftAzure\Storage\Blob\Models\CreateBlobPagesOptions::setLeaseId
  * @covers MicrosoftAzure\Storage\Blob\Models\CreateBlobPagesOptions::getLeaseId
  */
 public function testSetLeaseId()
 {
     // Setup
     $expected = '0x8CAFB82EFF70C46';
     $options = new CreateBlobPagesOptions();
     $options->setLeaseId($expected);
     // Test
     $options->setLeaseId($expected);
     // Assert
     $this->assertEquals($expected, $options->getLeaseId());
 }
Ejemplo n.º 2
0
 /**
  * Does actual work for create and clear blob pages.
  * 
  * @param string                 $action    Either clear or create.
  * @param string                 $container The container name.
  * @param string                 $blob      The blob name.
  * @param PageRange              $range     The page ranges.
  * @param string|resource        $content   The content stream.
  * @param CreateBlobPagesOptions $options   The optional parameters.
  * 
  * @return CreateBlobPagesResult
  */
 private function _updatePageBlobPagesImpl($action, $container, $blob, $range, $content, $options = null)
 {
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     Validate::isString($container, 'container');
     Validate::isTrue($range instanceof PageRange, sprintf(Resources::INVALID_PARAM_MSG, 'range', get_class(new PageRange())));
     Validate::isTrue(is_string($content) || is_resource($content), sprintf(Resources::INVALID_PARAM_MSG, 'content', 'string|resource'));
     $method = Resources::HTTP_PUT;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_CREATED;
     // If read file failed for any reason it will throw an exception.
     $body = is_resource($content) ? stream_get_contents($content) : $content;
     if (is_null($options)) {
         $options = new CreateBlobPagesOptions();
     }
     $headers = $this->_addOptionalRangeHeader($headers, $range->getStart(), $range->getEnd());
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $this->addOptionalHeader($headers, Resources::CONTENT_MD5, $options->getContentMD5());
     $this->addOptionalHeader($headers, Resources::X_MS_PAGE_WRITE, $action);
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::URL_ENCODED_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'page');
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode, $body);
     return CreateBlobPagesResult::create(HttpFormatter::formatHeaders($response->getHeaders()));
 }