/** * @covers WindowsAzure\Blob\Models\PageRange::__construct * @covers WindowsAzure\Blob\Models\PageRange::getStart * @covers WindowsAzure\Blob\Models\PageRange::getEnd */ public function test__construct() { // Setup $expectedStart = 0; $expectedEnd = 512; // Test $actual = new PageRange($expectedStart, $expectedEnd); // Assert $this->assertEquals($expectedStart, $actual->getStart()); $this->assertEquals($expectedEnd, $actual->getEnd()); return $actual; }
/** * 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($response->getHeader()); }